From e21c761d13faa158fb8445a0df4a7af666ea2782 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 7 Jun 2022 09:45:41 +0800 Subject: [PATCH] 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. --- src/xterm.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.39.2