Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Brown paper bag for 49915



The code would crash when n == 0. There's not really any point doing any
of this when n is 0 so just skip everything. It also tried to NULL
terminate a list a little to eagerly.
---
 Src/Zle/compcore.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index 99f58a0897..607ac25bb4 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -3247,7 +3247,7 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
 	    }
 	    *cp = NULL;
 	}
-    } else {
+    } else if (n > 0) {
 	if (!(flags & CGF_NOSORT)) {
 	    /* Now sort the array (it contains matches). */
 	    matchorder = flags;
@@ -3320,8 +3320,8 @@ makearray(LinkList l, int type, int flags, int *np, int *nlp, int *llp)
 			}
 			*ap = *bp;
 		    }
+		    *ap = NULL;
 		}
-		*ap = NULL;
 	    /* passed -1 but not -2, so remove consecutive duplicates (efficient) */
 	    } else if (!(flags & CGF_UNIQCON)) {
 		int dup;
-- 
2.15.1





Messages sorted by: Reverse Date, Date, Thread, Author