From: Nicholas Clark Date: Wed, 21 Oct 2009 10:06:43 +0000 (+0100) Subject: Make filter_read() in block mode create a well-formed SV with a trailing '\0' X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=881d8f0a6e1bd66255692969be386aba9ffe8762;p=p5sagit%2Fp5-mst-13.2.git Make filter_read() in block mode create a well-formed SV with a trailing '\0' --- diff --git a/toke.c b/toke.c index dba9ae3..d3d32eb 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) {