[gtk+] win32: do not crash on invalid utf8 conversion
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] win32: do not crash on invalid utf8 conversion
- Date: Sat, 23 Mar 2013 19:49:36 +0000 (UTC)
commit 564b4e667a046ff1e3eadff8de465496746a24ee
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Wed Mar 20 23:12:56 2013 +0100
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
gdk/win32/gdkproperty-win32.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/gdk/win32/gdkproperty-win32.c b/gdk/win32/gdkproperty-win32.c
index 7a3671b..a260322 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]