forked from osmocom/wireshark
Fix various small memory leaks & 1 invalid g_free (airpcap_gui_utils.c)
svn path=/trunk/; revision=24185
This commit is contained in:
parent
f67a7818b0
commit
e923010814
|
@ -559,6 +559,7 @@ static void dissect_80211n_mac_phy(tvbuff_t *tvb, packet_info *pinfo, proto_tree
|
|||
proto_item *ti = NULL;
|
||||
ptvcursor_t *csr = NULL;
|
||||
guint16 ext_frequency;
|
||||
gchar *chan_str;
|
||||
|
||||
if (!tree)
|
||||
return;
|
||||
|
@ -594,8 +595,10 @@ static void dissect_80211n_mac_phy(tvbuff_t *tvb, packet_info *pinfo, proto_tree
|
|||
ptvcursor_add_invalid_check(csr, hf_80211n_mac_phy_rssi_ant3_ext, 1, 255);
|
||||
|
||||
ext_frequency = tvb_get_letohs(ptvcursor_tvbuff(csr), ptvcursor_current_offset(csr));
|
||||
chan_str = ieee80211_mhz_to_str(ext_frequency);
|
||||
proto_tree_add_uint_format(ptvcursor_tree(csr), hf_80211n_mac_phy_ext_chan_freq, ptvcursor_tvbuff(csr),
|
||||
ptvcursor_current_offset(csr), 2, ext_frequency, "Ext. Channel frequency: %s", ieee80211_mhz_to_str(ext_frequency));
|
||||
ptvcursor_current_offset(csr), 2, ext_frequency, "Ext. Channel frequency: %s", chan_str);
|
||||
g_free(chan_str);
|
||||
ptvcursor_advance(csr, 2);
|
||||
|
||||
ptvcursor_add_with_subtree(csr, hf_80211n_mac_phy_ext_chan_flags, 2, TRUE,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
@ -591,6 +593,24 @@ airpcap_get_channel_name(UINT n)
|
|||
return g_strdup_printf("%d",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
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -174,6 +174,12 @@ airpcap_get_channel_name(UINT n);
|
|||
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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
17
gtk/main.c
17
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,
|
||||
|
|
Loading…
Reference in New Issue