diff options
Diffstat (limited to 'ext/PerlIO-encoding/encoding.xs')
-rw-r--r-- | ext/PerlIO-encoding/encoding.xs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ext/PerlIO-encoding/encoding.xs b/ext/PerlIO-encoding/encoding.xs index 98d89e9ef4..3f27dec740 100644 --- a/ext/PerlIO-encoding/encoding.xs +++ b/ext/PerlIO-encoding/encoding.xs @@ -365,6 +365,7 @@ PerlIOEncode_fill(pTHX_ PerlIO * f) /* Adjust ptr/cnt not taking anything which did not translate - not clear this is a win */ /* compute amount we took */ + if (!SvPOKp(e->dataSV)) (void)SvPV_force_nolen(e->dataSV); use -= SvCUR(e->dataSV); PerlIO_set_ptrcnt(n, ptr+use, (avail-use)); /* and as we did not take it it isn't pending */ @@ -440,6 +441,10 @@ PerlIOEncode_flush(pTHX_ PerlIO * f) if (PerlIO_flush(PerlIONext(f)) != 0) { code = -1; } + if (!SvPOKp(e->bufsv) || SvTHINKFIRST(e->bufsv)) + (void)SvPV_force_nolen(e->bufsv); + if ((STDCHAR *)SvPVX(e->bufsv) != e->base.buf) + e->base.buf = (STDCHAR *)SvPVX(e->bufsv); if (SvCUR(e->bufsv)) { /* Did not all translate */ e->base.ptr = e->base.buf+SvCUR(e->bufsv); |