]> Pileus Git - ~andy/gtk/commitdiff
gtkimcontexttime.c: Check context_ime->client_window is not NULL
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 29 Aug 2012 06:03:46 +0000 (14:03 +0800)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 3 Sep 2012 20:03:58 +0000 (16:03 -0400)
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

modules/input/gtkimcontextime.c

index 3dd06506e48c4cb668e0d858bdc6d525de267bcb..009af3febe08f1b495deea2f908dffbf30fedfac 100644 (file)
@@ -375,6 +375,8 @@ 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_WINDOW_HWND (context_ime->client_window);
   himc = ImmGetContext (hwnd);
   if (!himc)
@@ -434,6 +436,8 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
   HWND hwnd;
   HIMC himc;
 
+  if (!context_ime->client_window)
+    return attrs;
   hwnd = GDK_WINDOW_HWND (context_ime->client_window);
   himc = ImmGetContext (hwnd);
   if (!himc)