Mercurial > pidgin
diff src/util.c @ 5915:124ca6f5e895
[gaim-migrate @ 6347]
gaim_utf8_strcasecmp was crashing win32 on invalid UTF8 params
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Tue, 17 Jun 2003 22:45:02 +0000 |
parents | 964e4f94fc56 |
children | a4f2aba0848d |
line wrap: on
line diff
--- 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;