summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2016-01-20 15:35:13 +1100
committerTony Cook <tony@develop-help.com>2016-02-03 14:41:46 +1100
commit23c4e91245a43fb7bbe5215e27ca989e3b410552 (patch)
tree8c71325a2b7be23875d4dec17398c0bf0ef2b05e /toke.c
parentc95ea6823bf0611c3ce863cdc508a66b52523d34 (diff)
downloadperl-23c4e91245a43fb7bbe5215e27ca989e3b410552.tar.gz
[perl #125540] handle already being at EOF while not finding a heredoc terminator
In some cases, S_scan_heredoc() can already be at end of file and PL_rsfp is NULL. If we're on the final line and that line has no newline we'd assert or crash. Now, if we don't find that newline, we obviously can't find the terminator, so go straight to reporting the missing terminator. I considered setting s to PL_bufend, but that would just be more work to print the same message.
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/toke.c b/toke.c
index d2a7e7cc91..e2f2bfe830 100644
--- a/toke.c
+++ b/toke.c
@@ -9577,9 +9577,10 @@ S_scan_heredoc(pTHX_ char *s)
goto streaming;
}
}
- else { /* eval */
+ else { /* eval or we've already hit EOF */
s = (char*)memchr((void*)s, '\n', PL_bufend - s);
- assert(s);
+ if (!s)
+ goto interminable;
}
linestr = shared->ls_linestr;
bufend = SvEND(linestr);