]> git.eshelyaron.com Git - emacs.git/commitdiff
Prevent crashes with very large Motif targets tables
authorPo Lu <luangruo@yahoo.com>
Tue, 7 Jun 2022 01:45:41 +0000 (09:45 +0800)
committerPo Lu <luangruo@yahoo.com>
Tue, 7 Jun 2022 01:45:41 +0000 (09:45 +0800)
* src/xterm.c (xm_setup_dnd_targets): Catch errors around
xm_write_targets_table lest we get a BadAlloc error.

src/xterm.c

index ee396f38cc70e845e8f9589dac99954839a2e7a0..a11a22ab10c60f94d80abb1463c8c19ca0b37f84 100644 (file)
@@ -2029,9 +2029,16 @@ xm_setup_dnd_targets (struct x_display_info *dpyinfo,
         it back to 0.  There will probably be no more updates to the
         protocol either.  */
       header.protocol = XM_DRAG_PROTOCOL_VERSION;
+
+      x_catch_errors (dpyinfo->display);
       xm_write_targets_table (dpyinfo->display, drag_window,
                              dpyinfo->Xatom_MOTIF_DRAG_TARGETS,
                              &header, recs);
+      /* Presumably we got a BadAlloc upon writing the targets
+        table.  */
+      if (x_had_errors_p (dpyinfo->display))
+       idx = -1;
+      x_uncatch_errors_after_check ();
     }
 
   XUngrabServer (dpyinfo->display);