From 7c4a780721a64bf429bc87557922a46870a924c5 Mon Sep 17 00:00:00 2001 From: Po Lu Date: Tue, 24 May 2022 21:01:14 +0800 Subject: [PATCH] Prevent errors when Lisp code asks for props of invalid windows * src/xfns.c (Fx_window_property): (Fx_window_property_attributes): Catch X errors. --- src/xfns.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/xfns.c b/src/xfns.c index 94077e0af45..e1f8947d558 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -7563,6 +7563,8 @@ if PROP has no value of TYPE (always a string in the MS Windows case). */) } block_input (); + x_catch_errors (FRAME_X_DISPLAY (f)); + if (STRINGP (type)) { if (strcmp ("AnyPropertyType", SSDATA (type)) == 0) @@ -7593,6 +7595,9 @@ if PROP has no value of TYPE (always a string in the MS Windows case). */) &found); } + x_check_errors (FRAME_X_DISPLAY (f), + "Can't retrieve window property: %s"); + x_uncatch_errors_after_check (); unblock_input (); return prop_value; @@ -7638,6 +7643,7 @@ Otherwise, the return value is a vector with the following fields: block_input (); + x_catch_errors (FRAME_X_DISPLAY (f)); prop_atom = XInternAtom (FRAME_X_DISPLAY (f), SSDATA (prop), False); rc = XGetWindowProperty (FRAME_X_DISPLAY (f), target_window, prop_atom, 0, 0, False, AnyPropertyType, @@ -7668,6 +7674,10 @@ Otherwise, the return value is a vector with the following fields: make_fixnum (bytes_remaining / (actual_format >> 3))); } + x_check_errors (FRAME_X_DISPLAY (f), + "Can't retrieve window property: %s"); + x_uncatch_errors_after_check (); + unblock_input (); return prop_attr; } -- 2.39.2