Fix large memleak in decompression when output does not go to stdout. Same sort of logic already exists in compression.

This commit is contained in:
Tim Savannah 2017-06-04 01:29:17 -04:00
parent 6e0016daf7
commit 1510f4a26a

View file

@ -788,8 +788,9 @@ bool decompress_file(rzip_control *control)
} }
} }
if (unlikely(!open_tmpoutbuf(control))) if ( STDOUT )
return false; if (unlikely(!open_tmpoutbuf(control)))
return false;
if (!STDIN) { if (!STDIN) {
if (unlikely(!read_magic(control, fd_in, &expected_size))) if (unlikely(!read_magic(control, fd_in, &expected_size)))
@ -845,6 +846,9 @@ bool decompress_file(rzip_control *control)
else else
print_progress("[OK] \n"); print_progress("[OK] \n");
if (TMP_OUTBUF)
close_tmpoutbuf(control);
if (fd_out > 0) { if (fd_out > 0) {
if (unlikely(close(fd_hist) || close(fd_out))) if (unlikely(close(fd_hist) || close(fd_out)))
fatal_return(("Failed to close files\n"), false); fatal_return(("Failed to close files\n"), false);