aboutsummaryrefslogtreecommitdiffstats
path: root/ui/iface_lists.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-10-04 11:31:19 +0200
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2015-10-04 15:45:02 +0000
commitc647faa8a90739963ba40a099a365197f90b2184 (patch)
tree779aa416faca634eb3eb5dcd84e8421a75720ce2 /ui/iface_lists.c
parent49151eb28c421b61a89bd18feb509e9428909b1e (diff)
Fix various memleaks
Found by starting Wireshark within an empty profile, opening Preferences, search for Protocol "IEEE 802.11" (because it has radio buttons), then close everything again. Many fixes are trivial, but the various recent_read_* functions in recent.c were changed to return a boolean such that the result can always be checked even if errno==0. QButtonGroup leak was hinted by Clang Static Analyzer, all other memleaks were found using ASAN/LSan. Change-Id: Ia73f5d4c09d92f22e72377be59e23342f8ad7211 Reviewed-on: https://code.wireshark.org/review/10776 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Diffstat (limited to 'ui/iface_lists.c')
-rw-r--r--ui/iface_lists.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index 8c29dd357e..ba07c3eb7e 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -63,7 +63,7 @@ void
scan_local_interfaces(void (*update_cb)(void))
{
GList *if_entry, *lt_entry, *if_list;
- if_info_t *if_info, *temp;
+ if_info_t *if_info, temp;
char *if_string;
gchar *descr;
if_capabilities_t *caps=NULL;
@@ -130,14 +130,14 @@ scan_local_interfaces(void (*update_cb)(void))
}
device.hidden = FALSE;
device.locked = FALSE;
- temp = (if_info_t *)g_malloc0(sizeof(if_info_t));
- temp->name = g_strdup(if_info->name);
- temp->friendly_name = g_strdup(if_info->friendly_name);
- temp->vendor_description = g_strdup(if_info->vendor_description);
- temp->loopback = if_info->loopback;
- temp->type = if_info->type;
+ memset(&temp, 0, sizeof(temp));
+ temp.name = g_strdup(if_info->name);
+ temp.friendly_name = g_strdup(if_info->friendly_name);
+ temp.vendor_description = g_strdup(if_info->vendor_description);
+ temp.loopback = if_info->loopback;
+ temp.type = if_info->type;
#ifdef HAVE_EXTCAP
- temp->extcap = g_strdup(if_info->extcap);
+ temp.extcap = g_strdup(if_info->extcap);
#endif
/* Is this interface hidden and, if so, should we include it anyway? */
@@ -217,7 +217,7 @@ scan_local_interfaces(void (*update_cb)(void))
temp_addr = NULL;
}
if (temp_addr) {
- temp->addrs = g_slist_append(temp->addrs, temp_addr);
+ temp.addrs = g_slist_append(temp.addrs, temp_addr);
}
}
#ifdef HAVE_PCAP_REMOTE
@@ -274,7 +274,7 @@ scan_local_interfaces(void (*update_cb)(void))
device.addresses = g_strdup(ip_str->str);
device.no_addresses = ips;
device.local = TRUE;
- device.if_info = *temp;
+ device.if_info = temp;
device.last_packets = 0;
if (!capture_dev_user_pmode_find(if_info->name, &device.pmode)) {
device.pmode = global_capture_opts.default_options.promisc_mode;