From 479ab3bcdc8d79b27bfc99fcde073457f72126ac Mon Sep 17 00:00:00 2001 From: Mikael Kanstrup Date: Mon, 23 Nov 2015 16:33:40 +0100 Subject: Fix memory leak in capture_get_if_capabilities Valgrind reports memory leaks like these: 154 bytes in 10 blocks are possibly lost in loss record 8,660 of 11,855 at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xBD9EA38: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4) by 0xBDB3358: g_strndup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4) by 0xBDB49AD: g_strsplit (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.4) by 0x502291: capture_get_if_capabilities (capture_ifinfo.c:269) by 0x50A4CC: scan_local_interfaces (iface_lists.c:186) by 0x4C4BBD: refresh_local_interface_lists (capture_dlg.c:6117) by 0x504EC8: iface_mon_handler2 (iface_monitor.c:113) by 0xC9ADF1D: ??? (in /lib/libnl-3.so.200.3.0) by 0xC56DF19: ??? (in /usr/lib/libnl-route-3.so.200.3.0) by 0xC9ABE5E: nl_cache_parse (in /lib/libnl-3.so.200.3.0) by 0xC9AF5CA: nl_msg_parse (in /lib/libnl-3.so.200.3.0) Under certain conditions raw_list variable was not freed properly. Change-Id: Ibbaf0d67d983ee6912cfc9dc1a3169bc773b03c9 Reviewed-on: https://code.wireshark.org/review/12112 Reviewed-by: Peter Wu Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann --- capchild/capture_ifinfo.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'capchild') diff --git a/capchild/capture_ifinfo.c b/capchild/capture_ifinfo.c index 3a25f2fa22..b6bef3cf1e 100644 --- a/capchild/capture_ifinfo.c +++ b/capchild/capture_ifinfo.c @@ -278,6 +278,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode, if (err_str) { *err_str = g_strdup("Dumpcap returned no interface capability information"); } + g_strfreev(raw_list); return NULL; } @@ -302,6 +303,7 @@ capture_get_if_capabilities(const gchar *ifname, gboolean monitor_mode, raw_list[0]); } g_free(caps); + g_strfreev(raw_list); return NULL; } -- cgit v1.2.1