In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/295e8c06d82ac75b111246bf21d51c7f30b6aa10?hp=fb35b2c24f8da5fb8fa1a50fbab1868d072191db>
- Log ----------------------------------------------------------------- commit 295e8c06d82ac75b111246bf21d51c7f30b6aa10 Author: Nicholas Clark <[email protected]> Date: Wed Oct 21 12:41:21 2009 +0100 S_utf16_textfilter() was failing honour error returns from FILTER_READ() M toke.c commit c8b0cbae4027475c5e532bbdd2673bcb4dae0aa3 Author: Nicholas Clark <[email protected]> Date: Wed Oct 21 11:59:05 2009 +0100 panic if S_utf16_textfilter() is called in block mode. M toke.c commit 881d8f0a6e1bd66255692969be386aba9ffe8762 Author: Nicholas Clark <[email protected]> Date: Wed Oct 21 11:06:43 2009 +0100 Make filter_read() in block mode create a well-formed SV with a trailing '\0' M toke.c ----------------------------------------------------------------------- Summary of changes: toke.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/toke.c b/toke.c index dba9ae3..7ad492f 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) { @@ -12776,12 +12777,19 @@ S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen) const STRLEN old = SvCUR(sv); const I32 count = FILTER_READ(idx+1, sv, maxlen); const bool reverse = IoLINES(sv); + + /* As we're automatically added, at the lowest level, and hence only called + from this file, we can be sure that we're not called in block mode. Hence + don't bother writing code to deal with block mode. */ + if (maxlen) { + Perl_croak(aTHX_ "panic: utf16_textfilter called in block mode (for %d characters)", maxlen); + } DEBUG_P(PerlIO_printf(Perl_debug_log, "utf16%s_textfilter(%p): %d %d (%d)\n", reverse ? "rev" : "", FPTR2DPTR(void *, S_utf16_textfilter), idx, maxlen, (int) count)); - if (count) { + if (count > 0) { U8* tmps; I32 newlen; Newx(tmps, SvCUR(sv) * 3 / 2 + 1, U8); -- Perl5 Master Repository
