diff options
-rw-r--r-- | unprotbas.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/unprotbas.c b/unprotbas.c index 14fdc63..686b8c3 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -238,9 +238,13 @@ void breakcode(void) { } } - data[oldpos + 2] = 0; - if(verbose) - fprintf(stderr, "set invalid line length 0 at line %d, file offset %04x\n", lineno, oldpos + 2); + if(!oldpos) { + die("can't protect code because there are no lines of code"); + } else { + data[oldpos + 2] = 0; + if(verbose) + fprintf(stderr, "set invalid line length 0 at line %d, file offset %04x\n", lineno, oldpos + 2); + } } /* sometimes the variable name table isn't large enough to hold @@ -581,8 +585,13 @@ void scramble_vars(void) { for(i = vnstart; i < vvstart - 1; i++) data[i] = '\x9b'; - if(verbose) - fprintf(stderr, "replaced %d byte variable name table with EOLs.\n", i); + if(verbose) { + i -= vnstart; + if(i) + fprintf(stderr, "replaced %d byte variable name table with EOLs.\n", i); + else + die("can't protect variables because there are no variables."); + } } void print_help(void) { |