From 9107fb6039260ad2e84f303fd824dc66e62bdd24 Mon Sep 17 00:00:00 2001 From: Mikael Kanstrup Date: Mon, 23 Nov 2015 16:33:41 +0100 Subject: Fix memory leaks related to hide_interface function Valgrind report leaks like these: 6 bytes in 6 blocks are definitely lost in loss record 2,197 of 46,703 at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xA5C1610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA5D8B0E: g_strdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0x69A211: ManageInterfacesDialog::localAccepted() (manage_interfaces_dialog.cpp:454) by 0x69A500: ManageInterfacesDialog::on_buttonBox_accepted() (manage_interfaces_dialog.cpp:211) by 0x71DB32: ManageInterfacesDialog::qt_metacall(QMetaObject::Call, int, void**) (manage_interfaces_dialog.moc.cpp:245) by 0xBEBE36C: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xBEBE2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xAF87E41: QAbstractButton::clicked(bool) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11095: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11BAD: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11D23: QAbstractButton::mouseReleaseEvent(QMouseEvent*) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) 96 bytes in 4 blocks are definitely lost in loss record 42,458 of 52,779 at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) by 0xA5C1610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA5D722D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0xA5B84F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0) by 0x731F9A: hide_interface (iface_lists.c:426) by 0x69A211: ManageInterfacesDialog::localAccepted() (manage_interfaces_dialog.cpp:454) by 0x69A4F0: ManageInterfacesDialog::on_buttonBox_accepted() (manage_interfaces_dialog.cpp:211) by 0x71DB22: ManageInterfacesDialog::qt_metacall(QMetaObject::Call, int, void**) (manage_interfaces_dialog.moc.cpp:245) by 0xBEBE36C: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xBEBE2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1) by 0xAF87E41: QAbstractButton::clicked(bool) (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) by 0xAD11095: ??? (in /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.2.1) These are caused by leaks inside hide_interface function and among its users. Fixed by letting hide_interface function free its resources properly and making sure the users follow the pattern. Change-Id: I91527b83d36dc38b402d0f4a1db4b7db40fd83f9 Reviewed-on: https://code.wireshark.org/review/12113 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu --- ui/gtk/capture_dlg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/gtk/capture_dlg.c') diff --git a/ui/gtk/capture_dlg.c b/ui/gtk/capture_dlg.c index e9a4f22edd..a3f3390ce0 100644 --- a/ui/gtk/capture_dlg.c +++ b/ui/gtk/capture_dlg.c @@ -3956,7 +3956,7 @@ ok_remote_cb(GtkWidget *win _U_, gpointer *data _U_) } while (gtk_tree_model_iter_next(model, &iter)); g_free(name); } - hide_interface(g_strdup(new_hide)); + hide_interface(new_hide); /* Refresh all places that are displaying an interface list that includes interfaces other than local interfaces -- cgit v1.2.3