summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaxime de Roucy <maxime.deroucy@gmail.com>2017-07-02 16:58:20 +0200
committerPeter Stephenson <pws@zsh.org>2017-07-04 09:38:23 +0100
commitcdd9402224da17e90b674a135e0183291c3f38ec (patch)
treebf936126e9b611f451f8bdcdc37513a6fcabbada
parent6116fdb2779c7e1a8623d0f34a48c8fed2d144c5 (diff)
downloadzsh-cdd9402224da17e90b674a135e0183291c3f38ec.tar.gz
zsh-cdd9402224da17e90b674a135e0183291c3f38ec.tar.xz
zsh-cdd9402224da17e90b674a135e0183291c3f38ec.zip
Avoid invalid access with isearch in completion list
-rw-r--r--ChangeLog5
-rw-r--r--Src/Zle/complist.c12
2 files changed, 12 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index fb79b29f9..8a080f4ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-07-04  Peter Stephenson  <p.stephenson@samsung.com>
+
+	* Maxime de Roucy: 41385: Src/Zle/complist.c: Avoid invalid
+	access with isearch in completion list.
+
 2017-07-03  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* Sebastian: 41375: Src/Modules/db_gdbm.c: GDBM interface bug fixes.
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 035038815..a83daeff9 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -2334,11 +2334,6 @@ msearch(Cmatch **ptr, char *ins, int back, int rep, int *wrapp)
             }
         }
         if (x == ex && y == ey) {
-            if (wrap) {
-                msearchstate = MS_FAILED | owrap;
-                break;
-            }
-            msearchstate |= MS_WRAPPED;
 
             if (back) {
                 x = mcols - 1;
@@ -2350,6 +2345,13 @@ msearch(Cmatch **ptr, char *ins, int back, int rep, int *wrapp)
             }
             ex = mcol;
             ey = mline;
+
+            if (wrap || (x == ex && y == ey)) {
+                msearchstate = MS_FAILED | owrap;
+                break;
+            }
+
+            msearchstate |= MS_WRAPPED;
             wrap = 1;
             *wrapp = 1;
         }