Memory leak when wgetrc has invalid config
When the .wgetrc
file has an invalid config option (I tried using wget's new xattr = true
). Wget2 will leak about 10k of memory. The relevant stack trace is:
Direct leak of 10240 byte(s) in 1 object(s) allocated from:
#0 0x7ffff6efedf0 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:62
#1 0x7ffff6b0d2c6 in wget_malloc /home/thedoctor/Programming/wget2/libwget/xalloc.c:91
#2 0x7ffff6abf667 in wget_getline_internal /home/thedoctor/Programming/wget2/libwget/io.c:71
#3 0x7ffff6ac0b61 in wget_getline /home/thedoctor/Programming/wget2/libwget/io.c:184
#4 0x4167a5 in _read_config /home/thedoctor/Programming/wget2/src/options.c:974
#5 0x415e47 in _read_config /home/thedoctor/Programming/wget2/src/options.c:945
#6 0x416949 in read_config /home/thedoctor/Programming/wget2/src/options.c:1043
#7 0x4180e3 in init /home/thedoctor/Programming/wget2/src/options.c:1224
#8 0x410545 in main /home/thedoctor/Programming/wget2/tests/test.c:1544
#9 0x7ffff473c740 in __libc_start_main (/usr/lib/libc.so.6+0x20740)
The issue is that Wget2 calls set_long_option
on the option found in the config file. When the option is invalid, set_long_option
calls wget_printf_exit
and quits, without giving the caller a chance to free any allocated memory