diff --git a/main.c b/main.c index 84c958a..158ccaa 100644 --- a/main.c +++ b/main.c @@ -363,7 +363,7 @@ static void decompress_file(void) fatal("Failed to open history file %s\n", control.outfile); /* Unlink temporary file as soon as possible */ - if (unlikely(STDOUT && unlink(control.outfile))) + if (unlikely((STDOUT || TEST_ONLY) && unlink(control.outfile))) fatal("Failed to unlink tmpfile: %s\n", control.outfile); if (NO_MD5) @@ -681,6 +681,9 @@ static void compress_file(void) fd_out = open_tmpoutfile(); control.fd_out = fd_out; + if (unlikely(STDOUT && unlink(control.outfile))) + fatal("Failed to unlink tmpfile: %s\n", control.outfile); + preserve_perms(fd_in, fd_out); /* write zeroes to 24 bytes at beginning of file */