Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix complist menuselect segmentation fault
- X-seq: zsh-workers 41385
- From: Maxime de Roucy <maxime.deroucy@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Fix complist menuselect segmentation fault
- Date: Sun,  2 Jul 2017 16:58:20 +0200
- Cc: Maxime de Roucy <maxime.deroucy@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=gmail.com; s=20161025;        h=from:to:cc:subject:date:message-id:mime-version         :content-transfer-encoding;        bh=Qt8APWQmFX7QhJy9lmKY1JI3znS1aI2PNNQk31h6WL4=;        b=lN17sXdv342NHOKYGR+4IsEcMD1Us/VZjAmPGHIunxMMTzOjEoe5UejKIw/uRjMhq8         isopQEbEEY3RWUdfQXzHmu0QBfqfl2RroMZx99m5yjMnVhT9psNtMErqDDgPtnZiwyrp         fRa/J3BKZ6KmAb+PpY81soYPkq5Ruhz/L0rb2HM+FqG7+LDyB15vk+BHwp+b8kqDQcqH         BMSDqESg0FoxR7sYkplt45eY3VptvcHQQjPA4UOOGvwphiGeHmYxNSOoXGf6KsfxrD8w         zdMfeB0BYle5Kgb9ocYE5Sz7Qa7AnuTsJ+A49pnshyqE8WkucMheYeHx38ET7Y+85Vk8         2Y1Q==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Without this patch :
I use :
  zstyle ':completion:*:hosts' menu yes=long yes=20 select search
Imagine I have 2 hosts : "ab" and "bb"
When I try to use the completion menu ("isearch") and type "aa" the shell
crash (segmentation fault).
The first "a" match only host "ab", so when a type the second "a", mcol
and mline == 0.
The first time the code enter "if (x == ex && y == ey)", it leave the if
with x = y = ex = ey = 0.
Then "++x" (line 2331) increment x, and x and y can't match ex and ey
anymore since they can only increase.
→ segmentation fault
---
 Src/Zle/complist.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
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;
         }
-- 
2.13.2
Messages sorted by:
Reverse Date,
Date,
Thread,
Author