emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 4306091087: Improve last change to xterm.c


From: Po Lu
Subject: master 4306091087: Improve last change to xterm.c
Date: Wed, 23 Nov 2022 07:40:46 -0500 (EST)

branch: master
commit 43060910874f46579fa190d9b5534508e4ea058e
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    Improve last change to xterm.c
    
    * src/xfns.c (Fx_display_last_user_time): Reject overly large
    timestamps.
    * src/xterm.c (x_display_set_last_user_time, handle_one_xevent):
    New functions.
---
 src/xfns.c  |  6 ++++--
 src/xterm.c | 12 ++++++------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/xfns.c b/src/xfns.c
index 95092ce05f..fa2c0751d9 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -9728,10 +9728,12 @@ selected frame's display.  */)
   (Lisp_Object time_object, Lisp_Object terminal)
 {
   struct x_display_info *dpyinfo;
-  Time time;
+  uint32_t time;
 
+  /* time should be a 32-bit integer, regardless of what the size of
+     the X type `Time' is on this system.  */
   dpyinfo = check_x_display_info (terminal);
-  CONS_TO_INTEGER (time_object, Time, time);
+  CONS_TO_INTEGER (time_object, uint32_t, time);
 
   x_set_last_user_time_from_lisp (dpyinfo, time);
   return Qnil;
diff --git a/src/xterm.c b/src/xterm.c
index 732fbf462c..cfd8c385d1 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -7749,11 +7749,6 @@ x_display_set_last_user_time (struct x_display_info 
*dpyinfo, Time time,
   old_time = dpyinfo->last_user_time;
 #endif
 
-  /* Time can be sign extended if retrieved from a client message.
-     Make sure it is always 32 bits, or systems with 64-bit longs
-     will crash after 24 days of X server uptime.  (bug#59480) */
-  time &= X_ULONG_MAX;
-
 #ifdef ENABLE_CHECKING
   eassert (time <= X_ULONG_MAX);
 #endif
@@ -18626,7 +18621,12 @@ handle_one_xevent (struct x_display_info *dpyinfo,
                /* Set the provided time as the user time, which is
                   required for SetInputFocus to work correctly after
                   taking the input focus.  */
-               x_display_set_last_user_time (dpyinfo, event->xclient.data.l[1],
+
+               /* Time can be sign extended if retrieved from a client message.
+                  Make sure it is always 32 bits, or systems with 64-bit longs
+                  will crash after 24 days of X server uptime.  (bug#59480) */
+               x_display_set_last_user_time (dpyinfo, (event->xclient.data.l[1]
+                                                       & 0xffffffff),
                                              true, true);
                goto done;
               }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]