about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-07-28 17:03:58 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-07-28 17:03:58 +0000
commit72c6c2cdbce981a869868627ffb36aed5766f95c (patch)
treebbfb59381cc82d6a49762e7ac3c42b18d6956b4d
parent489169c853e1e1c387b84eae3858a4a7c42afde5 (diff)
downloadzsh-72c6c2cdbce981a869868627ffb36aed5766f95c.tar.gz
zsh-72c6c2cdbce981a869868627ffb36aed5766f95c.tar.xz
zsh-72c6c2cdbce981a869868627ffb36aed5766f95c.zip
zsh-workers:7308
-rw-r--r--Src/Zle/zle_tricky.c13
1 files 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++;