diff options
-rw-r--r-- | unprotbas.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/unprotbas.c b/unprotbas.c index 05a5f6e..c1c0e68 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -811,9 +811,10 @@ void parse_args(int argc, char **argv) { default: invalid_args(*argv); break; } } else { + /* arg doesn't start with a -, must be a filename */ if(!input_file) open_input(*argv); - else if(!checkonly && !output_file) + else if(!checkonly && !output_filename) output_filename = *argv; else invalid_args(*argv); @@ -890,6 +891,8 @@ int main(int argc, char **argv) { } } + /* we don't open the output file until all processing is done, to + avoid leaving invalid output files if we exit on error. */ open_output(output_filename); outbytes = fwrite(data, 1, filelen, output_file); fclose(output_file); |