fix memory leak in file zbarimg/zbarimg.c #300
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Reproduction:
export CC=afl-gcc CXX=afl-g++
poc_file:
poc.zip
LeakSanitizer result:
==4387==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 2168 byte(s) in 1 object(s) allocated from:
#0 0x7f8ffb014302 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
#1 0x7f8ffb6d0086 in NewMagickWand (/lib/libGraphicsMagickWand-Q16.so.2+0x20086)
#2 0x56305e2bdd07 in main zbarimg/zbarimg.c:448
#3 0x7f8ff9a29d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Indirect leak of 8536 byte(s) in 1 object(s) allocated from:
#0 0x7f8ffb014302 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
#1 0x7f8ffa69d627 in CloneImageInfo (/lib/libGraphicsMagick-Q16.so.3+0x9d627)
#2 0x56305e2bdd07 in main zbarimg/zbarimg.c:448
#3 0x7f8ff9a29d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
Indirect leak of 256 byte(s) in 1 object(s) allocated from:
#0 0x7f8ffb014302 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
#1 0x7f8ffa6ee847 in CloneString (/lib/libGraphicsMagick-Q16.so.3+0xee847)
Indirect leak of 133 byte(s) in 4 object(s) allocated from:
#0 0x7f8ffb014302 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
#1 0x7f8ffa6e9fc0 in AcquireString (/lib/libGraphicsMagick-Q16.so.3+0xe9fc0)
Indirect leak of 32 byte(s) in 1 object(s) allocated from:
#0 0x7f8ffb014302 in __interceptor_malloc ../../../../src/libsanitizer/lsan/lsan_interceptors.cpp:75
#1 0x7f8ffa6bf187 in CloneQuantizeInfo (/lib/libGraphicsMagick-Q16.so.3+0xbf187)
#2 0x56305e2bdd07 in main zbarimg/zbarimg.c:448
#3 0x7f8ff9a29d8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
SUMMARY: LeakSanitizer: 11125 byte(s) leaked in 8 allocation(s).