1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-10 12:40:58 +02:00

23511: error if here document too large

This commit is contained in:
Peter Stephenson 2007-06-03 17:44:20 +00:00
parent 4a1549e058
commit 023f6ce4e1
3 changed files with 22 additions and 1 deletions

View file

@ -1,3 +1,8 @@
2007-06-03 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 23511: Src/exec.c, Src/lex.c: error if here document
too large.
2007-06-02 Peter Stephenson <p.w.stephenson@ntlworld.com>
* unposted: Functions/Calendar/age, Functions/Example/zls:

View file

@ -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;

View file

@ -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;