diff -r f161fc3074d1 -r 46ba9c764edc pidgin/gtkthemes.c --- a/pidgin/gtkthemes.c Tue Nov 05 11:34:56 2013 +0200 +++ b/pidgin/gtkthemes.c Tue Nov 05 21:53:00 2013 -0500 @@ -225,6 +225,7 @@ FILE *f = g_fopen(file, "r"); char buf[256]; char *i; + gsize line_nbr = 0; struct smiley_theme *theme=NULL; struct smiley_list *list = NULL; GSList *lst = smiley_themes; @@ -260,6 +261,7 @@ if (!fgets(buf, sizeof(buf), f)) { break; } + line_nbr++; if (buf[0] == '#' || buf[0] == '\0') continue; @@ -271,6 +273,11 @@ continue; } + if (! g_utf8_validate(buf, -1, NULL)) { + purple_debug_error("gtkthemes", "%s:%d is invalid UTF-8\n", file, line_nbr); + continue; + } + i = buf; while (isspace(*i)) i++; @@ -309,10 +316,16 @@ while (*i) { char l[64]; int li = 0; + char *next; while (*i && !isspace(*i) && li < sizeof(l) - 1) { if (*i == '\\' && *(i+1) != '\0') i++; - l[li++] = *(i++); + next = g_utf8_next_char(i); + if ((next - i) > (sizeof(l) - li -1)) { + break; + } + while (i != next) + l[li++] = *(i++); } l[li] = 0; if (!sfile) {