Check FROM arg to substring in icomplete-completions
authorLeo Liu <sdl.web@gmail.com>
Mon, 20 Feb 2012 08:06:52 +0000 (16:06 +0800)
committerLeo Liu <sdl.web@gmail.com>
Mon, 20 Feb 2012 08:06:52 +0000 (16:06 +0800)
See: http://debbugs.gnu.org/10850

lisp/ChangeLog
lisp/icomplete.el

index cc58513..629b5b1 100644 (file)
@@ -1,3 +1,8 @@
+2012-02-20  Leo Liu  <sdl.web@gmail.com>
+
+       * icomplete.el (icomplete-completions): Check FROM arg before
+       passing to substring (Bug#10850).
+
 2012-02-19  Chong Yidong  <cyd@gnu.org>
 
        * comint.el: Require ansi-color.
index 80a0bf1..a971965 100644 (file)
@@ -347,7 +347,9 @@ are exhibited within the square braces.)"
            (setq prospects nil)
          (while (and comps (not limit))
            (setq comp
-                  (if prefix-len (substring (car comps) prefix-len) (car comps))
+                 (if (and prefix-len (<= prefix-len (length (car comps))))
+                     (substring (car comps) prefix-len)
+                   (car comps))
                  comps (cdr comps))
            (cond ((string-equal comp "") (setq most-is-exact t))
                  ((member comp prospects))