From 2d57ddd6ef0ef44382be7080484e2408375eb463 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 29 Aug 2012 14:03:46 +0800 Subject: [PATCH] gtkimcontexttime.c: Check context_ime->client_window is not NULL Be a bit more careful in get_pango_attr_list() and get_utf8_preedit_string() to ensure that the client_window is properly created before proceeding, to avoid access violation/segfault crashes on Windows with IME installed, especially when running the pickers demo. https://bugzilla.gnome.org/show_bug.cgi?id=682919 (cherry picked from commit a866ed737810ea32ec55260ad512f386a4e6df5d) --- modules/input/gtkimcontextime.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/input/gtkimcontextime.c b/modules/input/gtkimcontextime.c index b15f0f2581..468214653f 100644 --- a/modules/input/gtkimcontextime.c +++ b/modules/input/gtkimcontextime.c @@ -376,6 +376,9 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret) if (pos_ret) *pos_ret = 0; + if (!context_ime->client_window) + return g_strdup (""); + hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window); himc = ImmGetContext (hwnd); if (!himc) @@ -435,6 +438,9 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str) HWND hwnd; HIMC himc; + if (!context_ime->client_window) + return attrs; + hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window); himc = ImmGetContext (hwnd); if (!himc)