From: Po Lu Date: Tue, 7 Jun 2022 01:45:41 +0000 (+0800) Subject: Prevent crashes with very large Motif targets tables X-Git-Tag: emacs-29.0.90~1910^2~186 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=e21c761d13faa158fb8445a0df4a7af666ea2782;p=emacs.git Prevent crashes with very large Motif targets tables * src/xterm.c (xm_setup_dnd_targets): Catch errors around xm_write_targets_table lest we get a BadAlloc error. --- diff --git a/src/xterm.c b/src/xterm.c index ee396f38cc7..a11a22ab10c 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -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);