about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-06-03 17:44:20 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-06-03 17:44:20 +0000
commit023f6ce4e19331c3658c58955e178ca92783c5a1 (patch)
tree8e71f5c275b8b6714525f40edc0ebe4f9713ffa4 /Src
parent4a1549e058ac25d7ea9d2821292eeb5a3eefdd55 (diff)
downloadzsh-023f6ce4e19331c3658c58955e178ca92783c5a1.tar.gz
zsh-023f6ce4e19331c3658c58955e178ca92783c5a1.tar.xz
zsh-023f6ce4e19331c3658c58955e178ca92783c5a1.zip
23511: error if here document too large
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c8
-rw-r--r--Src/lex.c10
2 files changed, 17 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c
index ccba66bf8..7e4b55d43 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3111,7 +3111,13 @@ gethere(char *str, int typ)
 	    ;
 	for (;;) {
 	    if (bptr == buf + bsiz) {
-		buf = realloc(buf, 2 * bsiz);
+		char *newbuf = realloc(buf, 2 * bsiz);
+		if (!newbuf) {
+		    /* out of memory */
+		    zfree(buf, bsiz);
+		    return NULL;
+		}
+		buf = newbuf;
 		t = buf + bsiz - (bptr - t);
 		bptr = buf + bsiz;
 		bsiz *= 2;
diff --git a/Src/lex.c b/Src/lex.c
index 7748bedad..776eaf95a 100644
--- a/Src/lex.c
+++ b/Src/lex.c
@@ -356,6 +356,16 @@ yylex(void)
 	    ALLOWHIST
 	    cmdpop();
 	    hwend();
+	    if (!name) {
+		zerr("here document too large");
+		while (hdocs) {
+		    next = hdocs->next;
+		    zfree(hdocs, sizeof(struct heredocs));
+		    hdocs = next;
+		}
+		tok = LEXERR;
+		break;
+	    }
 	    setheredoc(hdocs->pc, REDIR_HERESTR, name);
 	    zfree(hdocs, sizeof(struct heredocs));
 	    hdocs = next;