emacs-diffs
[Top][All Lists]
Advanced

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

master 6d415d5f0b: Fix core dump with x-get-local-selection


From: Paul Eggert
Subject: master 6d415d5f0b: Fix core dump with x-get-local-selection
Date: Mon, 4 Jul 2022 17:22:26 -0400 (EDT)

branch: master
commit 6d415d5f0b616fc36f3e5c47a42b6af19eb3d82a
Author: Paul Eggert <eggert@cs.ucla.edu>
Commit: Paul Eggert <eggert@cs.ucla.edu>

    Fix core dump with x-get-local-selection
    
    * src/xselect.c (Fx_get_local_selection): Check that VALUE has 4
    elements, since x_get_local_selection can dump core otherwise.
    This pacifies gcc -Wanalyzer-null-dereference, which found the
    problem.
---
 src/xselect.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/xselect.c b/src/xselect.c
index 2521dc171c..1fda300c43 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -2325,9 +2325,13 @@ run.  */)
   Lisp_Object name, timestamp, frame, result;
 
   CHECK_SYMBOL (target);
-  name = Fnth (make_fixnum (0), value);
-  timestamp = Fnth (make_fixnum (2), value);
-  frame = Fnth (make_fixnum (3), value);
+
+  /* Check that VALUE has 4 elements, for x_get_local_selection.  */
+  Lisp_Object v = value; CHECK_CONS (v);
+  name = XCAR (v); v = XCDR (v); CHECK_CONS (v);
+  v = XCDR (v); CHECK_CONS (v);
+  timestamp = XCAR (v); v = XCDR (v); CHECK_CONS (v);
+  frame = XCAR (v);
 
   CHECK_SYMBOL (name);
   CONS_TO_INTEGER (timestamp, Time, time);



reply via email to

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