Fix leaks when spawning extcap processes

Valgrind reports leaks like these when spawning extcap processes (for
example when displaying or refreshing interface list with extcap
interfaces present):

3,917 (464 direct, 3,453 indirect) bytes in 29 blocks are definitely lost in loss record 58,301 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 0xA6B913B: g_error_new_valist (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6B94ED: g_set_error (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA710B03: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA710E17: g_spawn_sync (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C677: extcap_foreach (extcap.c:199)
   by 0x44CCAD: extcap_interface_list (extcap.c:413)
   by 0x72B548: capture_interface_list (capture_ifinfo.c:126)
   by 0x7336FA: scan_local_interfaces (iface_lists.c:141)
   by 0x55F01F: WiresharkApplication::refreshLocalInterfaces() (wireshark_application.cpp:898)
   ...

Change-Id: If8f750f5f8fa42a6f0884bb0e6bbbd71bd8f68aa
Reviewed-on: https://code.wireshark.org/review/13631
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
This commit is contained in:
Mikael Kanstrup 2016-01-31 20:55:55 +01:00 committed by Roland Knall
parent 14d6c205bd
commit a53ab9dfcc
1 changed files with 1 additions and 2 deletions

View File

@ -177,7 +177,6 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb,
gchar *command_output = NULL;
gboolean status = FALSE;
gint exit_status = 0;
GError *error = NULL;
gchar **envp = NULL;
/* full path to extcap binary */
@ -201,7 +200,7 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb,
status = g_spawn_sync(dirname, argv, envp,
(GSpawnFlags) 0, NULL, NULL,
&command_output, NULL, &exit_status, &error);
&command_output, NULL, &exit_status, NULL);
if (status && exit_status == 0)
keep_going = cb(extcap_path->str, ifname, command_output, cb_data, err_str);