[gaim-migrate @ 6347]

Tue, 17 Jun 2003 22:45:02 +0000

author
Herman Bloggs <herman@bluedigits.com>
date
Tue, 17 Jun 2003 22:45:02 +0000
changeset 5915
634fcb6e3e66
parent 5914
70c15057c4ea
child 5916
d340e341a298

[gaim-migrate @ 6347]
gaim_utf8_strcasecmp was crashing win32 on invalid UTF8 params

src/util.c file | annotate | diff | comparison | revisions
--- a/src/util.c	Tue Jun 17 20:14:05 2003 +0000
+++ b/src/util.c	Tue Jun 17 22:45:02 2003 +0000
@@ -991,9 +991,18 @@
 }
 
 gint gaim_utf8_strcasecmp(const gchar *a, const gchar *b) {
-	gchar *a_norm = g_utf8_casefold(a, -1);
-	gchar *b_norm = g_utf8_casefold(b, -1);
-	gint ret = g_utf8_collate(a_norm, b_norm);
+	gchar *a_norm=NULL;
+	gchar *b_norm=NULL;
+	gint ret=-1;
+
+	if(!g_utf8_validate(a, -1, NULL) || !g_utf8_validate(b, -1, NULL)) {
+		gaim_debug(GAIM_DEBUG_ERROR, "gaim_utf8_strcasecmp", "One or both parameters are invalid UTF8\n");
+		return ret;
+	}
+
+	a_norm = g_utf8_casefold(a, -1);
+	b_norm = g_utf8_casefold(b, -1);
+	ret = g_utf8_collate(a_norm, b_norm);
 	g_free(a_norm);
 	g_free(b_norm);
 	return ret;

mercurial