30cf0d107f
In the cases when a failure is experienced, the value "-1" was returned from the main() function without doing any cleanup or deinit. For example, if wlantest was started with the following set of command line arguments then later when returning after a failure from main() function, the memory allocated as part of handling the "-p" getopt command line option was not freed. To fix memory leaks in this case, properly free the previously allocated memory with the help of wlantest_deinit() before returning from main(). $ sudo valgrind --leak-check=full --show-leak-kinds=all --verbose \ > --track-origins=yes --log-file=valgrind-out.txt \ > ./wlantest -i hwsim0 -dd -c -p "asdfasdfasdfasdf" -W "abcd" Invalid WEP key 'abcd' Memory leak reported by Valgrind when running wlantest as mentioned above. ==513454== HEAP SUMMARY: ==513454== in use at exit: 128 bytes in 1 blocks ==513454== total heap usage: 4 allocs, 3 frees, 5,720 bytes allocated ==513454== ==513454== Searching for pointers to 1 not-freed blocks ==513454== Checked 76,936 bytes ==513454== ==513454== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==513454== at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==513454== by 0x1396CA: os_zalloc (in /home/ubuntu/hostap/wlantest/wlantest) ==513454== by 0x10C345: add_passphrase (wlantest.c:125) ==513454== by 0x10C345: main (wlantest.c:425) ==513454== ==513454== LEAK SUMMARY: ==513454== definitely lost: 128 bytes in 1 blocks ==513454== indirectly lost: 0 bytes in 0 blocks ==513454== possibly lost: 0 bytes in 0 blocks ==513454== still reachable: 0 bytes in 0 blocks ==513454== suppressed: 0 bytes in 0 blocks ==513454== ==513454== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0) Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com> |
||
---|---|---|
.. | ||
.gitignore | ||
bip.c | ||
bss.c | ||
ccmp.c | ||
ctrl.c | ||
gcmp.c | ||
inject.c | ||
Makefile | ||
monitor.c | ||
process.c | ||
readpcap.c | ||
rx_data.c | ||
rx_eapol.c | ||
rx_ip.c | ||
rx_mgmt.c | ||
rx_tdls.c | ||
sta.c | ||
test_vectors.c | ||
tkip.c | ||
wep.c | ||
wired.c | ||
wlantest.c | ||
wlantest.h | ||
wlantest_cli.c | ||
wlantest_ctrl.h | ||
writepcap.c |