]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix core dump with x-get-local-selection
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Jul 2022 21:21:35 +0000 (16:21 -0500)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Jul 2022 21:22:17 +0000 (16:22 -0500)
* 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

index 2521dc171c0fae10627ed5e46c8f4e16d0102818..1fda300c431f8140d9fe7d3ad9af4fc6a31dca89 100644 (file)
@@ -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);