From 1510f4a26a31479084c3d8e47543d2657a3935ad Mon Sep 17 00:00:00 2001 From: Tim Savannah Date: Sun, 4 Jun 2017 01:29:17 -0400 Subject: [PATCH] Fix large memleak in decompression when output does not go to stdout. Same sort of logic already exists in compression. --- lrzip.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lrzip.c b/lrzip.c index 659fbff..d4ad141 100644 --- a/lrzip.c +++ b/lrzip.c @@ -788,8 +788,9 @@ bool decompress_file(rzip_control *control) } } - if (unlikely(!open_tmpoutbuf(control))) - return false; + if ( STDOUT ) + if (unlikely(!open_tmpoutbuf(control))) + return false; if (!STDIN) { if (unlikely(!read_magic(control, fd_in, &expected_size))) @@ -845,6 +846,9 @@ bool decompress_file(rzip_control *control) else print_progress("[OK] \n"); + if (TMP_OUTBUF) + close_tmpoutbuf(control); + if (fd_out > 0) { if (unlikely(close(fd_hist) || close(fd_out))) fatal_return(("Failed to close files\n"), false);