Mercurial > pidgin.yaz
comparison 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 |
comparison
equal
deleted
inserted
replaced
5914:1344aeab6baa | 5915:124ca6f5e895 |
---|---|
989 | 989 |
990 return g_strdup(inet_ntoa(((struct sockaddr_in *)&addr)->sin_addr)); | 990 return g_strdup(inet_ntoa(((struct sockaddr_in *)&addr)->sin_addr)); |
991 } | 991 } |
992 | 992 |
993 gint gaim_utf8_strcasecmp(const gchar *a, const gchar *b) { | 993 gint gaim_utf8_strcasecmp(const gchar *a, const gchar *b) { |
994 gchar *a_norm = g_utf8_casefold(a, -1); | 994 gchar *a_norm=NULL; |
995 gchar *b_norm = g_utf8_casefold(b, -1); | 995 gchar *b_norm=NULL; |
996 gint ret = g_utf8_collate(a_norm, b_norm); | 996 gint ret=-1; |
997 | |
998 if(!g_utf8_validate(a, -1, NULL) || !g_utf8_validate(b, -1, NULL)) { | |
999 gaim_debug(GAIM_DEBUG_ERROR, "gaim_utf8_strcasecmp", "One or both parameters are invalid UTF8\n"); | |
1000 return ret; | |
1001 } | |
1002 | |
1003 a_norm = g_utf8_casefold(a, -1); | |
1004 b_norm = g_utf8_casefold(b, -1); | |
1005 ret = g_utf8_collate(a_norm, b_norm); | |
997 g_free(a_norm); | 1006 g_free(a_norm); |
998 g_free(b_norm); | 1007 g_free(b_norm); |
999 return ret; | 1008 return ret; |
1000 } | 1009 } |
1001 | 1010 |