From: Evgeny Vereshchagin Date: Wed, 31 Mar 2021 09:35:57 +0000 (+0000) Subject: confile: fix a memory leak lxc_config_define_add X-Git-Tag: lxc-5.0.0~216^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a46f8537ecfb1229564fa13ce6cd864bc5a4ca6;p=thirdparty%2Flxc.git confile: fix a memory leak lxc_config_define_add ``` 2021-04-02T05:45:54.9410345Z ==13==ERROR: LeakSanitizer: detected memory leaks 2021-04-02T05:45:54.9410737Z 2021-04-02T05:45:54.9411488Z Direct leak of 16 byte(s) in 1 object(s) allocated from: 2021-04-02T05:45:54.9412556Z #0 0x54d752 in calloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:154:3 2021-04-02T05:45:54.9413360Z #1 0x583795 in parse_new_conf_line /src/lxc/src/lxc/confile.c:3048:8 2021-04-02T05:45:54.9414057Z #2 0x582f1a in lxc_config_define_add /src/lxc/src/lxc/confile.c:3090:15 2021-04-02T05:45:54.9415352Z #3 0x5810fa in LLVMFuzzerTestOneInput /src/lxc/src/tests/fuzz-lxc-define-load.c:30:6 2021-04-02T05:45:54.9419212Z #4 0x483b93 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:599:15 2021-04-02T05:45:54.9421819Z #5 0x48309a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:505:3 2021-04-02T05:45:54.9424205Z #6 0x485474 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:814:7 2021-04-02T05:45:54.9426658Z #7 0x485689 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:845:3 2021-04-02T05:45:54.9428616Z #8 0x473717 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:906:6 2021-04-02T05:45:54.9429989Z #9 0x49f572 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:20:10 2021-04-02T05:45:54.9433312Z #10 0x7fa96041b83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f) 2021-04-02T05:45:54.9433795Z 2021-04-02T05:45:54.9434661Z DEDUP_TOKEN: calloc--parse_new_conf_line--lxc_config_define_add 2021-04-02T05:45:54.9435483Z SUMMARY: AddressSanitizer: 16 byte(s) leaked in 1 allocation(s). 2021-04-02T05:45:54.9435958Z 2021-04-02T05:45:54.9436404Z INFO: a leak has been found in the initial corpus. ``` Signed-off-by: Evgeny Vereshchagin --- diff --git a/src/lxc/confile.c b/src/lxc/confile.c index 2fba09a4e..b1fd8652f 100644 --- a/src/lxc/confile.c +++ b/src/lxc/confile.c @@ -3127,6 +3127,7 @@ void lxc_config_define_free(struct lxc_list *defines) free(new_item->key); free(new_item->val); lxc_list_del(it); + free(it->elem); free(it); } }