From 9c27c7f7ceaf1f2a5120c915732140877cfa9ff0 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Sat, 11 Jun 2022 11:13:48 +0800 Subject: [PATCH] Handle allocation errors when interning large amounts of atoms * src/xfns.c (Fx_begin_drag): Catch BadAlloc errors around XInternAtoms. --- src/xfns.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/xfns.c b/src/xfns.c index 43d4d27372e..9882fd7ce11 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -6982,10 +6982,14 @@ that mouse buttons are being held down, such as immediately after a target_atoms = SAFE_ALLOCA (ntargets * sizeof *target_atoms); - block_input (); + /* Catch errors since interning lots of targets can potentially + generate a BadAlloc error. */ + x_catch_errors (FRAME_X_DISPLAY (f)); XInternAtoms (FRAME_X_DISPLAY (f), target_names, ntargets, False, target_atoms); - unblock_input (); + x_check_errors (FRAME_X_DISPLAY (f), + "Failed to intern target atoms: %s"); + x_uncatch_errors_after_check (); lval = x_dnd_begin_drag_and_drop (f, FRAME_DISPLAY_INFO (f)->last_user_time, xaction, return_frame, action_list, -- 2.39.2