Skip to content

Commit f013c0d

Browse files
committed
Avoid memory leak on error path
This isn't covered by the tests, but manually failing this allocation in vgdb results in a leak otherwise: 268,096 (5,952 direct, 262,144 indirect) bytes in 1 blocks are definitely lost in loss record 1,574 of 1,601 at 0x48407B4: malloc (vg_replace_malloc.c:381) by 0x74ACD86: deflateInit2_ (in /lib/x86_64-linux-gnu/libz.so.1.2.13) by 0x90EA5232: init_stream (fwrite.c:576) by 0x90EA5EB0: fwriteMain (fwrite.c:806) by 0x90EA79EE: fwriteR (fwriteR.c:310)
1 parent b17832e commit f013c0d

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/fwrite.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,7 @@ void fwriteMain(fwriteMainArgs args)
823823
if (!zbuffPool) {
824824
// # nocov start
825825
free(buffPool);
826+
deflateEnd(&strm);
826827
STOP(_("Unable to allocate %zu MiB * %d thread compressed buffers; '%d: %s'. Please read ?fwrite for nThread, buffMB and verbose options."),
827828
zbuffSize / MEGA, nth, errno, strerror(errno));
828829
// # nocov end

0 commit comments

Comments
 (0)