From: Paul Eggert Date: Mon, 4 Jul 2022 21:21:35 +0000 (-0500) Subject: Fix core dump with x-get-local-selection X-Git-Tag: emacs-29.0.90~1447^2~1189 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=6d415d5f0b616fc36f3e5c47a42b6af19eb3d82a;p=emacs.git 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. --- 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);