From 5a0afdf1cb2ef276a2b6e4cf26abf18405127db2 Mon Sep 17 00:00:00 2001 From: Ken Brown Date: Wed, 17 Nov 2021 12:20:24 -0500 Subject: [PATCH] Avoid an accidental use of an infinite timeout * src/xselect.c (x_get_foreign_selection): If x-selection-timeout is zero, call wait_reading_process_output with a zero timeout rather than an infinite timeout. (Bug#50043) --- src/xselect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xselect.c b/src/xselect.c index cd6d86bdf4..53b41f1ea2 100644 --- a/src/xselect.c +++ b/src/xselect.c @@ -1196,6 +1196,10 @@ x_get_foreign_selection (Lisp_Object selection_symbol, Lisp_Object target_type, intmax_t timeout = max (0, x_selection_timeout); intmax_t secs = timeout / 1000; int nsecs = (timeout % 1000) * 1000000; + /* If x_selection_timeout == 0, avoid the "zero means infinite" + behavior of wait_reading_process_output. */ + if (secs == 0 && nsecs == 0) + nsecs = -1; TRACE1 (" Start waiting %"PRIdMAX" secs for SelectionNotify", secs); wait_reading_process_output (secs, nsecs, 0, false, reading_selection_reply, NULL, 0); -- 2.33.0