branch: master
commit 1c042909445f13484da091d1432a1e542ae20bdf
Author: nathan moreau <[email protected]>
Commit: Oleh Krehel <[email protected]>

    Protect against match-beginning / match-end not integerp.
    
    This triggered an error on (swiper "[^ ]") (see #1188).
    Fixes #1188
    Fixes #1192
---
 swiper.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/swiper.el b/swiper.el
index 49cdd9d..36359d9 100644
--- a/swiper.el
+++ b/swiper.el
@@ -655,15 +655,18 @@ WND, when specified is the window."
               (while (<= (cl-incf j) ivy--subexps)
                 (let ((bm (match-beginning j))
                       (em (match-end j)))
-                  (while (and (< j ivy--subexps)
-                              (= em (match-beginning (+ j 1))))
-                    (setq em (match-end (cl-incf j))))
-                  (swiper--add-overlay
-                   bm em
-                   (nth (1+ (mod (+ i 2) (1- (length swiper-faces))))
-                        swiper-faces)
-                   wnd i)
-                  (cl-incf i))))))))))
+                  (when (and (integerp em)
+                             (integerp bm))
+                    (while (and (< j ivy--subexps)
+                                (integerp (match-beginning (+ j 1)))
+                                (= em (match-beginning (+ j 1))))
+                      (setq em (match-end (cl-incf j))))
+                    (swiper--add-overlay
+                     bm em
+                     (nth (1+ (mod (+ i 2) (1- (length swiper-faces))))
+                          swiper-faces)
+                     wnd i)
+                    (cl-incf i)))))))))))
 
 (defun swiper--add-overlay (beg end face wnd priority)
   "Add overlay bound by BEG and END to `swiper--overlays'.

Reply via email to