about summary refs log tree commit diff
path: root/Src/exec.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2018-07-10 14:42:02 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2018-07-10 14:42:02 +0100
commit3e9fc32fc3d6ac4931f82d666fa4f2f52ac5f65b (patch)
treee004d8df004fe157740f72986cd0bb5c1ea79cfb /Src/exec.c
parent17178db1a4d8700c9e10862d0dd496f92c53f1cd (diff)
downloadzsh-3e9fc32fc3d6ac4931f82d666fa4f2f52ac5f65b.tar.gz
zsh-3e9fc32fc3d6ac4931f82d666fa4f2f52ac5f65b.tar.xz
zsh-3e9fc32fc3d6ac4931f82d666fa4f2f52ac5f65b.zip
43156, 43157: Need to allow for extra space in gethere().
The point can now increment twice per iteration.
Diffstat (limited to 'Src/exec.c')
-rw-r--r--Src/exec.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 586402070..615a5086f 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -4418,7 +4418,9 @@ gethere(char **strp, int typ)
 	while ((c = hgetc()) == '\t' && strip)
 	    ;
 	for (;;) {
-	    if (bptr == buf + bsiz) {
+	    if (bptr >= buf + bsiz - 2) {
+		ptrdiff_t toff = t - buf;
+		ptrdiff_t bptroff = bptr - buf;
 		char *newbuf = realloc(buf, 2 * bsiz);
 		if (!newbuf) {
 		    /* out of memory */
@@ -4426,8 +4428,8 @@ gethere(char **strp, int typ)
 		    return NULL;
 		}
 		buf = newbuf;
-		t = buf + bsiz - (bptr - t);
-		bptr = buf + bsiz;
+		t = buf + toff;
+		bptr = buf + bptroff;
 		bsiz *= 2;
 	    }
 	    if (lexstop || c == '\n')