summaryrefslogtreecommitdiff
path: root/extcap.c
diff options
context:
space:
mode:
authorMikael Kanstrup <mikael.kanstrup@gmail.com>2016-01-31 07:40:33 +0100
committerRoland Knall <rknall@gmail.com>2016-01-31 10:48:53 +0000
commit96acb62c823f1c9bb0739593419998973fc6d8ea (patch)
treee6c717fc2b3bbe7ed06da4a960956eefd481b061 /extcap.c
parent27ff4ac18dea8372f0a2088ef4229a1d07c6541a (diff)
downloadwireshark-96acb62c823f1c9bb0739593419998973fc6d8ea.tar.gz
Fix memleaks on interface refresh when extcap configs exists
If there are extcap interfaces present then each time the capture interfaces list is displayed or refreshed a number of extcap related allocations are leaked. Valgrind reports leaks like these: 2,007 (144 direct, 1,863 indirect) bytes in 6 blocks are definitely lost in loss record 64,328 of 65,138 at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0x44C9AF: search_cb (extcap.c:451) by 0x44C6FC: extcap_foreach (extcap.c:204) by 0x44CDFF: extcap_get_if_configuration (extcap.c:473) by 0x44CE3C: extcap_has_configuration (extcap.c:489) by 0x654356: InterfaceTree::display() (interface_tree.cpp:199) by 0x6547DF: InterfaceTree::getInterfaceList() (interface_tree.cpp:252) by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0x563F9A: WiresharkApplication::allSystemsGo() (wireshark_application.cpp:914) by 0x4478D9: main (wireshark-qt.cpp:1373) 9,126 (432 direct, 8,694 indirect) bytes in 18 blocks are definitely lost in loss record 58,524 of 58,638 at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0x44C9AF: search_cb (extcap.c:451) by 0x44C6FC: extcap_foreach (extcap.c:204) by 0x44CDFF: extcap_get_if_configuration (extcap.c:473) by 0x44CE3C: extcap_has_configuration (extcap.c:489) by 0x654356: InterfaceTree::display() (interface_tree.cpp:199) by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0x4A3214: MainWindow::on_actionCaptureRefreshInterfaces_triggered() (main_window_slots.cpp:3605) ... Change-Id: I9433b8e36813cbef9dca5ab08074e985793f4d0d Reviewed-on: https://code.wireshark.org/review/13617 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r--extcap.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/extcap.c b/extcap.c
index a608787dc3..df40bd1017 100644
--- a/extcap.c
+++ b/extcap.c
@@ -417,6 +417,11 @@ extcap_interface_list(char **err_str) {
return g_list_sort ( ret, if_info_compare );
}
+static void extcap_free_arg_elem(gpointer data, gpointer user_data _U_) {
+ extcap_free_arg((extcap_arg *) data);
+ g_free(data);
+}
+
static void extcap_free_if_configuration(GList *list)
{
GList *elem, *sl;
@@ -426,7 +431,7 @@ static void extcap_free_if_configuration(GList *list)
if (elem->data != NULL) {
/* g_list_free_full() only exists since 2.28. */
sl = g_list_first((GList *)elem->data);
- g_list_foreach(sl, (GFunc)g_free, NULL);
+ g_list_foreach(sl, (GFunc)extcap_free_arg_elem, NULL);
g_list_free(sl);
}
}
@@ -505,6 +510,7 @@ extcap_has_configuration(const char * ifname, gboolean is_required) {
}
walker = walker->next;
}
+ extcap_free_if_configuration(arguments);
return found;
}