X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Fprop.c;h=44d0f2bf064c9aae0b76aa6b9702fc98d824e641;hb=ac4e6784ddd59635df0e51210257c506cff4dc25;hp=c53f250321a627a4021bd3c4af185a05d00c27e9;hpb=f8bbe46bce7597304d10d106ae51af43af88ca66;p=chaz%2Fopenbox diff --git a/openbox/prop.c b/openbox/prop.c index c53f2503..44d0f2bf 100644 --- a/openbox/prop.c +++ b/openbox/prop.c @@ -306,12 +306,17 @@ gboolean prop_get_strings_locale(Window win, Atom prop, char ***ret) gboolean prop_get_string_utf8(Window win, Atom prop, char **ret) { char *raw; + char *str; guint num; if (get_all(win, prop, prop_atoms.utf8, 8, (guchar**)&raw, &num)) { - *ret = g_strndup(raw, num); /* grab the first string from the list */ + str = g_strndup(raw, num); /* grab the first string from the list */ g_free(raw); - return TRUE; + if (g_utf8_validate(str, -1, NULL)) { + *ret = str; + return TRUE; + } + g_free(str); } return FALSE; } @@ -327,7 +332,10 @@ gboolean prop_get_strings_utf8(Window win, Atom prop, char ***ret) p = raw; for (i = 0; i < num; ++i) { - (*ret)[i] = g_strdup(p); + if (g_utf8_validate(p, -1, NULL)) + (*ret)[i] = g_strdup(p); + else + (*ret)[i] = g_strdup(""); p += strlen(p) + 1; } g_free(raw);