]> git.eshelyaron.com Git - emacs.git/commitdiff
Avoid crashes under 'which-key-mode'
authorEli Zaretskii <eliz@gnu.org>
Tue, 25 Jul 2023 17:38:01 +0000 (20:38 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sun, 30 Jul 2023 07:23:05 +0000 (10:23 +0300)
* src/keyboard.c (Fthis_single_command_keys): Don't allow calls to
Fvector with negative first argument.  (Bug#64857)

(cherry picked from commit 65834b8f8d53402517da7fe2446f5bac0aa30c39)

src/keyboard.c

index 99f886821e2bb0e7d6d7c7f9f152868174c1e30c..101a6f3a78e181bb1ac4b01dfcb5f797ed53e854 100644 (file)
@@ -11116,8 +11116,8 @@ the command loop or by `read-key-sequence'.
 The value is always a vector.  */)
   (void)
 {
-  return Fvector (this_command_key_count
-                 - this_single_command_key_start,
+  ptrdiff_t nkeys = this_command_key_count - this_single_command_key_start;
+  return Fvector (nkeys < 0 ? 0 : nkeys,
                  (XVECTOR (this_command_keys)->contents
                   + this_single_command_key_start));
 }