From 72c6c2cdbce981a869868627ffb36aed5766f95c Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 28 Jul 1999 17:03:58 +0000 Subject: zsh-workers:7308 --- Src/Zle/zle_tricky.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index cb2f90125..b38b1c0cc 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -6283,8 +6283,8 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) gen_matches_files(1, 0, 0); /* The compctl has a glob pattern (compctl -g). */ if (cc->glob) { - int ns, pl = strlen(prpre), o; - char *g = dupstring(cc->glob), pa[PATH_MAX]; + int ns, pl = strlen(prpre), o, paalloc; + char *g = dupstring(cc->glob), *pa; char *p2, *p3; int ne = noerrs, md = opts[MARKDIRS]; @@ -6298,8 +6298,9 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) } noerrs = 1; addwhat = -6; + o = strlen(prpre); + pa = (char *)zalloc(paalloc = o + PATH_MAX); strcpy(pa, prpre); - o = strlen(pa); opts[MARKDIRS] = 0; /* The compctl -g string may contain more than * @@ -6338,6 +6339,10 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) else { /* It's a simple pattern, so append it to * * the path we have on the command line. */ + int minlen = o + strlen(g); + if (minlen > paalloc) + pa = (char *) + zrealloc(pa, paalloc = minlen+1); strcpy(pa + o, g); addlinknode(l, dupstring(pa)); } @@ -6383,6 +6388,8 @@ makecomplistflags(Compctl cc, char *s, int incmd, int compadd) glob_pre = glob_suf = NULL; noerrs = ne; opts[MARKDIRS] = md; + + zfree(pa, paalloc); } } dirs++; -- cgit 1.4.1