From 6d415d5f0b616fc36f3e5c47a42b6af19eb3d82a Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 4 Jul 2022 16:21:35 -0500 Subject: [PATCH] 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 2521dc171c0..1fda300c431 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); -- 2.39.5