emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 d13029cdcde 2/7: Avoid crashes under 'which-key-mode'


From: Eli Zaretskii
Subject: emacs-29 d13029cdcde 2/7: Avoid crashes under 'which-key-mode'
Date: Sun, 30 Jul 2023 03:29:35 -0400 (EDT)

branch: emacs-29
commit d13029cdcde22b8e68d91d8f0c0b2649f72675f2
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Avoid crashes under 'which-key-mode'
    
    * 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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/keyboard.c b/src/keyboard.c
index 99f886821e2..101a6f3a78e 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -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));
 }



reply via email to

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