zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Brown paper bag for 49915
@ 2022-04-02 23:10 Mikael Magnusson
  0 siblings, 0 replies; only message in thread
From: Mikael Magnusson @ 2022-04-02 23:10 UTC (permalink / raw)
  To: zsh-workers

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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-02 23:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-02 23:10 PATCH: Brown paper bag for 49915 Mikael Magnusson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).