]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent crashes from illegal locale coding systems
authorPo Lu <luangruo@yahoo.com>
Sun, 13 Feb 2022 10:19:51 +0000 (18:19 +0800)
committerPo Lu <luangruo@yahoo.com>
Sun, 13 Feb 2022 10:20:42 +0000 (18:20 +0800)
* src/xfns.c (xic_preedit_draw_callback):
* src/xterm.c (handle_one_xevent): Don't pass invalid coding
systems to `setup_coding_system'.

src/xfns.c
src/xterm.c

index 02994e1b94f5ec7f1d8fc04c3b9dc61341ea6529..c490dc1802a64bfbd8a6129aae32e3bd4e7ba1f1 100644 (file)
@@ -3198,6 +3198,14 @@ xic_preedit_draw_callback (XIC xic, XPointer client_data,
       if (!output->preedit_active)
        return;
 
+      /* If we don't bail out here then GTK can crash
+        from the resulting signal in `setup_coding_system'.  */
+      if (NILP (Fcoding_system_p (Vlocale_coding_system)))
+       {
+         text = NULL;
+         goto im_abort;
+       }
+
       if (call_data->text)
        text = x_xim_text_to_utf8_unix (call_data->text, &text_length);
       else
index 50b7c9a606706044958e1b1138153d536ad644dc..fe213b0fabbab997b2417ad31c3d5566236538ea 100644 (file)
@@ -10024,6 +10024,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
            if (nchars < nbytes)
              {
+               /* If we don't bail out here then GTK can crash
+                  from the resulting signal in `setup_coding_system'.  */
+               if (NILP (Fcoding_system_p (coding_system)))
+                 goto done_keysym;
+
                /* Decode the input data.  */
 
                /* The input should be decoded with `coding_system'
@@ -11763,6 +11768,11 @@ handle_one_xevent (struct x_display_info *dpyinfo,
 
                  if (nchars < nbytes)
                    {
+                     /* If we don't bail out here then GTK can crash
+                        from the resulting signal in `setup_coding_system'.  */
+                     if (NILP (Fcoding_system_p (Vlocale_coding_system)))
+                       goto xi_done_keysym;
+
                      /* Decode the input data.  */
 
                      setup_coding_system (Vlocale_coding_system, &coding);