aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/filter_autocomplete.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2010-05-27 00:49:01 +0000
committerGerald Combs <gerald@wireshark.org>2010-05-27 00:49:01 +0000
commitb3a83551a322d9f8ccecec52e07a19670e345bbe (patch)
tree6b3c3827be411e854e079aee46b29bc6f3531c07 /gtk/filter_autocomplete.c
parent391b5127d6f416f883472fb7ed68bcf37f7581d9 (diff)
Make sure our prefix length is > 0 before lopping off the last
character. Fixes bug 4797. svn path=/trunk/; revision=32987
Diffstat (limited to 'gtk/filter_autocomplete.c')
-rw-r--r--gtk/filter_autocomplete.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/gtk/filter_autocomplete.c b/gtk/filter_autocomplete.c
index f72ba99ffc..1fa3cd5096 100644
--- a/gtk/filter_autocomplete.c
+++ b/gtk/filter_autocomplete.c
@@ -382,7 +382,7 @@ filter_string_te_key_pressed_cb(GtkWidget *filter_te, GdkEventKey *event)
}
return FALSE;
}
-
+
/* Let prefix points to the first char that is not aphanumeric,'.', '_' or '-',
* start from the end of filter_te_str.
**/
@@ -772,16 +772,20 @@ filter_autocomplete_handle_backspace(GtkWidget *filter_te, GtkWidget *list, GtkW
size_t prefix_len;
gboolean protocols_only = FALSE;
- /* Delete the last character in the prefix string */
- prefix_len = strlen(prefix)-1;
- prefix[prefix_len] = '\0';
+ prefix_len = strlen(prefix);
- if (prefix_len == 0) {
+ if (prefix_len < 1) {
/* Remove the popup window for protocols */
gtk_widget_destroy(popup_win);
g_object_set_data(G_OBJECT(main_win), E_FILT_AUTOCOMP_PTR_KEY, NULL);
return;
- } else if(strchr(prefix, '.') == NULL) {
+ }
+
+ /* Delete the last character in the prefix string */
+ prefix_len--;
+ prefix[prefix_len] = '\0';
+
+ if(strchr(prefix, '.') == NULL) {
protocols_only = TRUE;
}