diff options
author | Han Han <hanhanzhiyeqianke@gmail.com> | 2021-10-24 13:32:32 +0800 |
---|---|---|
committer | Han Han <hanhanzhiyeqianke@gmail.com> | 2021-10-24 13:56:02 +0800 |
commit | 66eaeed8592813fb12bc252e64e45c82ab0cec84 (patch) | |
tree | 9818a4f8273daeb229f4abee0e6d95c68d5d96d4 | |
parent | b256d4049cd7a9fd08e5a767c56d2011e3cc2c20 (diff) | |
download | libtiff-git-66eaeed8592813fb12bc252e64e45c82ab0cec84.tar.gz |
tiffsplit.c: Fix memleak before exit
Details of the memleak:
$ valgrind --leak-check=full tiffsplit id:001763,sync:fuzzer07,src:001641,+cov
==2090657==
==2090657== HEAP SUMMARY:
==2090657== in use at exit: 13,517 bytes in 17 blocks
==2090657== total heap usage: 41 allocs, 24 frees, 29,351 bytes allocated
==2090657==
==2090657== 2,473 (1,249 direct, 1,224 indirect) bytes in 1 blocks are definitely lost in loss record 10 of 13
==2090657== at 0x484086F: malloc (vg_replace_malloc.c:381)
==2090657== by 0x48BF35C: TIFFClientOpen (tif_open.c:118)
==2090657== by 0x48CF058: TIFFFdOpen (tif_unix.c:209)
==2090657== by 0x48CF0C4: TIFFOpen (tif_unix.c:248)
==2090657== by 0x10954C: main (tiffsplit.c:91)
==2090657==
==2090657== 11,044 (1,300 direct, 9,744 indirect) bytes in 1 blocks are definitely lost in loss record 13 of 13
==2090657== at 0x484086F: malloc (vg_replace_malloc.c:381)
==2090657== by 0x48BF35C: TIFFClientOpen (tif_open.c:118)
==2090657== by 0x48CF058: TIFFFdOpen (tif_unix.c:209)
==2090657== by 0x48CF0C4: TIFFOpen (tif_unix.c:248)
==2090657== by 0x1093D9: main (tiffsplit.c:75)
==2090657==
==2090657== LEAK SUMMARY:
==2090657== definitely lost: 2,549 bytes in 2 blocks
==2090657== indirectly lost: 10,968 bytes in 15 blocks
==2090657== possibly lost: 0 bytes in 0 blocks
==2090657== still reachable: 0 bytes in 0 blocks
==2090657== suppressed: 0 bytes in 0 blocks
==2090657==
==2090657== For lists of detected and suppressed errors, rerun with: -s
==2090657== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
Signed-off-by: Han Han <hanhanzhiyeqianke@gmail.com>
-rw-r--r-- | tools/tiffsplit.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/tiffsplit.c b/tools/tiffsplit.c index 296d6bf9..ffcd00f2 100644 --- a/tools/tiffsplit.c +++ b/tools/tiffsplit.c @@ -91,10 +91,16 @@ main(int argc, char* argv[]) out = TIFFOpen(path, TIFFIsBigEndian(in)?"wb":"wl"); _TIFFfree(path); - if (out == NULL) + if (out == NULL) { + TIFFClose(in); return (EXIT_FAILURE); - if (!tiffcp(in, out)) + } + if (!tiffcp(in, out)) { + TIFFClose(in); + TIFFClose(out); return (EXIT_FAILURE); + + } TIFFClose(out); } while (TIFFReadDirectory(in)); |