changeset 18447:8fc91e437981

Possible crash fix.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 06 Jul 2007 06:14:31 +0000
parents 197ac83893a5
children 4b1e2aefeb9d ed17f5530300
files finch/libgnt/gntmenu.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntmenu.c	Fri Jul 06 05:51:08 2007 +0000
+++ b/finch/libgnt/gntmenu.c	Fri Jul 06 06:14:31 2007 +0000
@@ -116,18 +116,20 @@
 	}
 }
 
-#define GET_VAL(ch)  ((ch >= '0' && ch <= '9') ? (ch - '0') : (ch >= 'a' && ch <= 'z') ? (10 + ch - 'a') : ch)
+#define GET_VAL(ch)  ((ch >= '0' && ch <= '9') ? (ch - '0') : (ch >= 'a' && ch <= 'z') ? (10 + ch - 'a') : 36)
 
 static void
 assign_triggers(GntMenu *menu)
 {
 	GList *iter;
-	gboolean bools[36];
+	gboolean bools[37];
 
 	memset(bools, 0, sizeof(bools));
+	bools[36] = 1;
+
 	for (iter = menu->list; iter; iter = iter->next) {
 		GntMenuItem *item = iter->data;
-		char trigger = gnt_menuitem_get_trigger(item);
+		char trigger = tolower(gnt_menuitem_get_trigger(item));
 		if (trigger == '\0' || trigger == ' ')
 			continue;
 		bools[(int)GET_VAL(trigger)] = 1;
@@ -141,7 +143,7 @@
 			continue;
 		while (*text) {
 			char ch = tolower(*text++);
-			if (bools[(int)GET_VAL(ch)])
+			if (ch == ' ' || bools[(int)GET_VAL(ch)])
 				continue;
 			trigger = ch;
 			break;