diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2018-06-06 14:01:06 +0200 |
---|---|---|
committer | Roland Knall <rknall@gmail.com> | 2018-06-06 12:39:17 +0000 |
commit | 26be9318101cd277c2007e7effa63e8789a922a4 (patch) | |
tree | 116b20d7e9cae3c5e959f404e36f870b67f32537 /extcap.c | |
parent | e8493fa7c4a741df245da8b8117e3c430cfe73b3 (diff) |
extcap: Fix a potential leak of memory pointed to by 'toolbar_entry'
Initialize toolbar_entry after error checking is done to avoid a
potential memory leak when exiting early from cb_load_interfaces().
Change-Id: I925d9296085964c6d5c3a9ccae85137285bf9220
Reviewed-on: https://code.wireshark.org/review/28060
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
Diffstat (limited to 'extcap.c')
-rw-r--r-- | extcap.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1648,12 +1648,6 @@ static gboolean cb_load_interfaces(extcap_callback_info_t cb_info) /* Load interfaces from utility */ interfaces = extcap_parse_interfaces(cb_info.output, &control_items); - if (control_items) - { - toolbar_entry = g_new0(iface_toolbar, 1); - toolbar_entry->controls = control_items; - } - g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "Loading interface list for %s ", cb_info.extcap); /* Seems, that there where no interfaces to be loaded */ @@ -1680,6 +1674,12 @@ static gboolean cb_load_interfaces(extcap_callback_info_t cb_info) return FALSE; } + if (control_items) + { + toolbar_entry = g_new0(iface_toolbar, 1); + toolbar_entry->controls = control_items; + } + walker = interfaces; gchar* help = NULL; while (walker != NULL) |