diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-10-21 11:06:43 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-10-21 11:06:43 +0100 |
commit | 881d8f0a6e1bd66255692969be386aba9ffe8762 (patch) | |
tree | 93afbd3c033f6dca9929a95cd37347c0a3fb7908 /toke.c | |
parent | fb35b2c24f8da5fb8fa1a50fbab1868d072191db (diff) | |
download | perl-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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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) { |