[gtk+/2.24: 2/7] win32: do not crash on invalid utf8 conversion
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/2.24: 2/7] win32: do not crash on invalid utf8 conversion
- Date: Thu, 24 Apr 2014 14:05:15 +0000 (UTC)
commit 1eb140f785acccd891c0b8bd09d45cfe30b690f1
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 39163b5..9a7537b 100644
--- a/gdk/win32/gdkproperty-win32.c
+++ b/gdk/win32/gdkproperty-win32.c
@@ -158,6 +158,7 @@ gdk_property_change (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));
@@ -201,7 +202,13 @@ gdk_property_change (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]