memory leak in mpca_lang function
NotmebutWind opened this issue · 0 comments
there is memory leak in mpca_lang function
1、 compile the lib with asan : make CC=gcc -fsanitize=address -g
2、test.c:
example/foobar.c
3、input:
char* foobar = "#@$^^&^(\x00";
argv[1] = "#@$^^&^(\x00";
4 compile and run ,find crash:
=================================================================
==2182132==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 72 byte(s) in 1 object(s) allocated from:
#0 0x7fc4e00dc867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55a33cc0476e in mpc_malloc ../mpc.c:241
#2 0x55a33cc09120 in mpc_err_or ../mpc.c:760
#3 0x55a33cc0a6ed in mpc_err_merge ../mpc.c:878
#4 0x55a33cc0e3b8 in mpc_parse_input ../mpc.c:1318
#5 0x55a33cc1fc6b in mpca_lang_st ../mpc.c:3724
#6 0x55a33cc2068b in mpca_lang ../mpc.c:3794
#7 0x55a33cc02f7e in fuzzloop ../examples/foobar.c:11
#8 0x55a33cc2ac89 in fuzzFunction ./wrapentry.c:98
Indirect leak of 192 byte(s) in 3 object(s) allocated from:
#0 0x7fc4e00dc867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55a33cc04b7f in mpc_export ../mpc.c:289
#2 0x55a33cc08b50 in mpc_err_export ../mpc.c:723
#3 0x55a33cc0e3cd in mpc_parse_input ../mpc.c:1318
#4 0x55a33cc1fc6b in mpca_lang_st ../mpc.c:3724
#5 0x55a33cc2068b in mpca_lang ../mpc.c:3794
#6 0x55a33cc02f7e in fuzzloop ../examples/foobar.c:11
#7 0x55a33cc2ac89 in fuzzFunction ./wrapentry.c:98
Indirect leak of 64 byte(s) in 1 object(s) allocated from:
#0 0x7fc4e00dc867 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:145
#1 0x55a33cc04b7f in mpc_export ../mpc.c:289
#2 0x55a33cc08c69 in mpc_err_export ../mpc.c:726
#3 0x55a33cc0e3cd in mpc_parse_input ../mpc.c:1318
#4 0x55a33cc1fc6b in mpca_lang_st ../mpc.c:3724
#5 0x55a33cc2068b in mpca_lang ../mpc.c:3794
#6 0x55a33cc02f7e in fuzzloop ../examples/foobar.c:11
#7 0x55a33cc2ac89 in fuzzFunction ./wrapentry.c:98
Indirect leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc4e00dcc18 in __interceptor_realloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:164
#1 0x55a33cc04abe in mpc_realloc ../mpc.c:274
#2 0x55a33cc08ee4 in mpc_err_add_expected ../mpc.c:743
#3 0x55a33cc09a14 in mpc_err_or ../mpc.c:787
#4 0x55a33cc0a6ed in mpc_err_merge ../mpc.c:878
#5 0x55a33cc0e3b8 in mpc_parse_input ../mpc.c:1318
#6 0x55a33cc1fc6b in mpca_lang_st ../mpc.c:3724
#7 0x55a33cc2068b in mpca_lang ../mpc.c:3794
#8 0x55a33cc02f7e in fuzzloop ../examples/foobar.c:11
#9 0x55a33cc2ac89 in fuzzFunction ./wrapentry.c:98
SUMMARY: AddressSanitizer: 352 byte(s) leaked in 6 allocation(s).