]> code.delx.au - gnu-emacs/commitdiff
Avoid crashes when key-binding is called from a timer
authorEli Zaretskii <eliz@gnu.org>
Mon, 8 Jun 2015 14:39:35 +0000 (17:39 +0300)
committerEli Zaretskii <eliz@gnu.org>
Mon, 8 Jun 2015 14:39:35 +0000 (17:39 +0300)
* src/keymap.c (Fkey_binding): Don't segfault if called with an
empty vector as KEY.  (Bug#20705)

src/keymap.c

index 8f4ac0dd437c13d2f68a18b62dd34db6f49ee1df..b69b409fc2d8410ea43c3a27439c7db7a8818fff 100644 (file)
@@ -1652,10 +1652,14 @@ specified buffer position instead of point are used.
 
   if (NILP (position) && VECTORP (key))
     {
-      Lisp_Object event
-       /* mouse events may have a symbolic prefix indicating the
-          scrollbar or mode line */
-       = AREF (key, SYMBOLP (AREF (key, 0)) && ASIZE (key) > 1 ? 1 : 0);
+      Lisp_Object event;
+
+      if (ASIZE (key) == 0)
+       return Qnil;
+
+      /* mouse events may have a symbolic prefix indicating the
+        scrollbar or mode line */
+      event = AREF (key, SYMBOLP (AREF (key, 0)) && ASIZE (key) > 1 ? 1 : 0);
 
       /* We are not interested in locations without event data */