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:
committed by
Matthias Clasen
parent
7ffaab3f91
commit
564b4e667a
@ -150,6 +150,7 @@ _gdk_win32_window_change_property (GdkWindow *window,
|
|||||||
guchar *ucptr;
|
guchar *ucptr;
|
||||||
wchar_t *wcptr, *p;
|
wchar_t *wcptr, *p;
|
||||||
glong wclen;
|
glong wclen;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
g_return_if_fail (window != NULL);
|
g_return_if_fail (window != NULL);
|
||||||
g_return_if_fail (GDK_IS_WINDOW (window));
|
g_return_if_fail (GDK_IS_WINDOW (window));
|
||||||
@ -193,7 +194,13 @@ _gdk_win32_window_change_property (GdkWindow *window,
|
|||||||
return;
|
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 */
|
wclen++; /* Terminating 0 */
|
||||||
size = wclen * 2;
|
size = wclen * 2;
|
||||||
|
|||||||
Reference in New Issue
Block a user