aboutsummaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2008-01-24 22:26:05 +0000
committerwmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7>2008-01-24 22:26:05 +0000
commitb84d6df18a1c7ce2d5c0ecc7039518ebaa50b5df (patch)
tree1d234ccd9c8c816238ed8f4b328abee42cddf427 /gtk
parent8b8be73b8ebc6c7db721d2f60951ace03a6c9d1b (diff)
Fix various small memory leaks & 1 invalid g_free (airpcap_gui_utils.c)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24185 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r--gtk/airpcap_dlg.c2
-rw-r--r--gtk/airpcap_gui_utils.c34
-rw-r--r--gtk/airpcap_gui_utils.h6
-rw-r--r--gtk/capture_if_dlg.c4
-rw-r--r--gtk/main.c17
5 files changed, 46 insertions, 17 deletions
diff --git a/gtk/airpcap_dlg.c b/gtk/airpcap_dlg.c
index 7b6febaafb..b4195ef464 100644
--- a/gtk/airpcap_dlg.c
+++ b/gtk/airpcap_dlg.c
@@ -2201,6 +2201,7 @@ display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
channel_cm_items = g_list_append(channel_cm_items, ieee80211_mhz_to_str(airpcap_if_selected->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(channel_cm), channel_cm_items);
+ airpcap_free_channel_combo_list (channel_cm_items);
}
/* Select the first entry */
@@ -2209,7 +2210,6 @@ display_airpcap_advanced_cb(GtkWidget *w, gpointer data)
airpcap_update_channel_combo(GTK_WIDGET(channel_cm), airpcap_if_selected);
}
- g_list_free (channel_cm_items);
channel_en = GTK_COMBO (channel_cm)->entry;
gtk_editable_set_editable(GTK_EDITABLE(channel_en),FALSE);
diff --git a/gtk/airpcap_gui_utils.c b/gtk/airpcap_gui_utils.c
index cd65a1f230..07aaf409fb 100644
--- a/gtk/airpcap_gui_utils.c
+++ b/gtk/airpcap_gui_utils.c
@@ -77,6 +77,7 @@ airpcap_get_all_channels_list(airpcap_if_info_t* if_info)
airpcap_if_info_t* current_adapter;
GString *freq_str = g_string_new("");
gchar *sep = "";
+ gchar *chan_str;
if(airpcap_if_is_any(if_info))
{
@@ -88,8 +89,9 @@ airpcap_get_all_channels_list(airpcap_if_info_t* if_info)
current_adapter = (airpcap_if_info_t*)current_item->data;
if(current_adapter != if_info && g_ascii_strncasecmp("AirPcap USB wireless capture adapter nr.", current_adapter->description, 40) == 0)
{
- g_string_sprintfa(freq_str, "%s%s", sep,
- ieee80211_mhz_to_str(current_adapter->channelInfo.Frequency));
+ chan_str = ieee80211_mhz_to_str(current_adapter->channelInfo.Frequency);
+ g_string_sprintfa(freq_str, "%s%s", sep, chan_str);
+ g_free(chan_str);
sep = ", ";
}
}
@@ -170,7 +172,7 @@ airpcap_set_toolbar_start_capture(airpcap_if_info_t* if_info)
channel_list = g_list_append(channel_list, ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(airpcap_toolbar_channel), channel_list);
- g_list_free(channel_list);
+ airpcap_free_channel_combo_list(channel_list);
}
airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
@@ -270,7 +272,7 @@ airpcap_set_toolbar_stop_capture(airpcap_if_info_t* if_info)
channel_list = g_list_append(channel_list, ieee80211_mhz_to_str(if_info->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(airpcap_toolbar_channel), channel_list);
- g_list_free(channel_list);
+ airpcap_free_channel_combo_list(channel_list);
}
airpcap_update_channel_combo(GTK_WIDGET(airpcap_toolbar_channel),if_info);
@@ -592,6 +594,24 @@ airpcap_get_channel_name(UINT n)
}
/*
+ * Free a channel combo list
+ */
+static void
+free_channel_string(gpointer data, gpointer user_data _U_)
+{
+ g_free(data);
+}
+
+void
+airpcap_free_channel_combo_list(GList *channel_list)
+{
+ if (channel_list != NULL) {
+ g_list_foreach(channel_list, free_channel_string, NULL);
+ g_list_free(channel_list);
+ }
+}
+
+/*
* Set the combo box entry string given an UINT channel number
*/
void
@@ -600,7 +620,7 @@ airpcap_channel_combo_set_by_number(GtkWidget* w,UINT chan_freq)
gchar *entry_text;
entry_text = ieee80211_mhz_to_str(chan_freq);
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),ieee80211_mhz_to_str(chan_freq));
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(w)->entry),entry_text);
g_free(entry_text);
}
@@ -644,7 +664,7 @@ airpcap_update_channel_offset_cb(airpcap_if_info_t* if_info, ULONG ch_freq, GtkW
}
current_offset = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(channel_offset_cb)->entry));
- strcpy (current_offset_copy, current_offset);
+ g_strlcpy (current_offset_copy, current_offset, sizeof(current_offset_copy));
chan_flags = airpcap_load_channel_offset_cb(if_info, channel_offset_cb, ch_freq);
new_offset_str = current_offset_copy;
@@ -672,8 +692,6 @@ airpcap_update_channel_offset_cb(airpcap_if_info_t* if_info, ULONG ch_freq, GtkW
if (!airpcap_update_frequency_and_offset(if_info)){
simple_dialog(ESD_TYPE_ERROR,ESD_BTN_OK,"Adapter failed to be set with the following settings: Frequency - %ld Extension Channel - %d", if_info->channelInfo.Frequency, if_info->channelInfo.ExtChannel);
}
-
- g_free(new_offset_str);
}
/*
diff --git a/gtk/airpcap_gui_utils.h b/gtk/airpcap_gui_utils.h
index 5139de8941..61aff05d76 100644
--- a/gtk/airpcap_gui_utils.h
+++ b/gtk/airpcap_gui_utils.h
@@ -175,6 +175,12 @@ void
airpcap_channel_combo_set_by_number(GtkWidget* w,UINT channel);
/*
+ * Free a channel combo list
+ */
+void
+airpcap_free_channel_combo_list(GList *channel_list);
+
+/*
* Returns '1' if this is the "Any" adapter, '0' otherwise
*/
int
diff --git a/gtk/capture_if_dlg.c b/gtk/capture_if_dlg.c
index cccad4491f..53ea74f316 100644
--- a/gtk/capture_if_dlg.c
+++ b/gtk/capture_if_dlg.c
@@ -299,6 +299,7 @@ capture_if_destroy_cb(GtkWidget *win _U_, gpointer user_data)
#endif
}
+#if 0
GtkWidget*
combo_channel_new(void)
{
@@ -327,7 +328,7 @@ combo_channel_new(void)
popdown = g_list_append(popdown, "14");
gtk_combo_set_popdown_strings( GTK_COMBO(channel_cb), popdown) ;
-
+ g_list_free(popdown);
#if GTK_MAJOR_VERSION < 2
gtk_widget_set_usize( GTK_WIDGET(channel_cb),
45,
@@ -341,6 +342,7 @@ combo_channel_new(void)
return channel_cb;
}
+#endif
/*
* Sorts the Interface List in alphabetical order
diff --git a/gtk/main.c b/gtk/main.c
index ab9fb78133..d5fc9fc4a8 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -4462,6 +4462,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
GtkTooltips *airpcap_tooltips;
/* gchar *if_label_text; */
gint *from_widget = NULL;
+ gchar *chan_str;
#endif
/* Display filter construct dialog has an Apply button, and "OK" not
@@ -4611,8 +4612,7 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
channel_list = g_list_append(channel_list, ieee80211_mhz_to_str(airpcap_if_active->pSupportedChannels[i].Frequency));
}
gtk_combo_set_popdown_strings( GTK_COMBO(channel_cm), channel_list);
- /* XXX: Need to free the items in the list before freeing the list */
- /* g_list_free(channel_list); */
+ airpcap_free_channel_combo_list(channel_list);
}
gtk_tooltips_set_tip(airpcap_tooltips, GTK_WIDGET(GTK_COMBO(channel_cm)->entry),
@@ -4620,11 +4620,14 @@ create_main_window (gint pl_size, gint tv_size, gint bv_size, e_prefs *prefs)
WIDGET_SET_SIZE(channel_cm, 120, 28);
- if(airpcap_if_active != NULL)
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry), ieee80211_mhz_to_str(airpcap_if_active->channelInfo.Frequency));
- else
- gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry),"");
-
+ if(airpcap_if_active != NULL) {
+ chan_str = ieee80211_mhz_to_str(airpcap_if_active->channelInfo.Frequency);
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry), chan_str);
+ g_free(chan_str);
+ }
+ else {
+ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(channel_cm)->entry),"");
+ }
gtk_widget_show(channel_cm);
gtk_toolbar_append_widget(GTK_TOOLBAR(airpcap_tb), channel_cm,