win32: do not crash on invalid utf8 conversion

g_utf8_to_utf16() is not guaranteed to succeed. Check the error
and return if it failed.

https://bugzilla.gnome.org/show_bug.cgi?id=696232
This commit is contained in:
Marc-André Lureau 2013-03-20 23:12:56 +01:00 committed by Matthias Clasen
parent 7ffaab3f91
commit 564b4e667a

View File

@ -150,6 +150,7 @@ _gdk_win32_window_change_property (GdkWindow *window,
guchar *ucptr;
wchar_t *wcptr, *p;
glong wclen;
GError *err = NULL;
g_return_if_fail (window != NULL);
g_return_if_fail (GDK_IS_WINDOW (window));
@ -193,7 +194,13 @@ _gdk_win32_window_change_property (GdkWindow *window,
return;
}
wcptr = g_utf8_to_utf16 ((char *) data, nelements, NULL, &wclen, NULL);
wcptr = g_utf8_to_utf16 ((char *) data, nelements, NULL, &wclen, &err);
if (err != NULL)
{
g_warning ("Failed to convert utf8: %s", err->message);
g_clear_error (&err);
return;
}
wclen++; /* Terminating 0 */
size = wclen * 2;