summaryrefslogtreecommitdiff
path: root/toke.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2009-10-21 11:06:43 +0100
committerNicholas Clark <nick@ccl4.org>2009-10-21 11:06:43 +0100
commit881d8f0a6e1bd66255692969be386aba9ffe8762 (patch)
tree93afbd3c033f6dca9929a95cd37347c0a3fb7908 /toke.c
parentfb35b2c24f8da5fb8fa1a50fbab1868d072191db (diff)
downloadperl-881d8f0a6e1bd66255692969be386aba9ffe8762.tar.gz
Make filter_read() in block mode create a well-formed SV with a trailing '\0'
Diffstat (limited to 'toke.c')
-rw-r--r--toke.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/toke.c b/toke.c
index dba9ae3029..d3d32ebf71 100644
--- a/toke.c
+++ b/toke.c
@@ -2917,7 +2917,7 @@ Perl_filter_read(pTHX_ int idx, SV *buf_sv, int maxlen)
const int old_len = SvCUR(buf_sv);
/* ensure buf_sv is large enough */
- SvGROW(buf_sv, (STRLEN)(old_len + correct_length)) ;
+ SvGROW(buf_sv, (STRLEN)(old_len + correct_length + 1)) ;
if ((len = PerlIO_read(PL_rsfp, SvPVX(buf_sv) + old_len,
correct_length)) <= 0) {
if (PerlIO_error(PL_rsfp))
@@ -2926,6 +2926,7 @@ Perl_filter_read(pTHX_ int idx, SV *buf_sv, int maxlen)
return 0 ; /* end of file */
}
SvCUR_set(buf_sv, old_len + len) ;
+ SvPVX(buf_sv)[old_len + len] = '\0';
} else {
/* Want a line */
if (sv_gets(buf_sv, PL_rsfp, SvCUR(buf_sv)) == NULL) {