From: Rafael Garcia-Suarez Date: Thu, 11 Jan 2007 10:34:02 +0000 (+0000) Subject: Fix bug #40407: after a seek on a PerlIO::scalar filehandle, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8b8eea963147e9111f99b4c1bf3eb8b60fe51935;p=p5sagit%2Fp5-mst-13.2.git Fix bug #40407: after a seek on a PerlIO::scalar filehandle, ensure there's a string buffer in the scalar p4raw-id: //depot/perl@29751 --- diff --git a/ext/PerlIO/scalar/scalar.xs b/ext/PerlIO/scalar/scalar.xs index 319c851..b31e681 100644 --- a/ext/PerlIO/scalar/scalar.xs +++ b/ext/PerlIO/scalar/scalar.xs @@ -108,6 +108,10 @@ PerlIOScalar_seek(pTHX_ PerlIO * f, Off_t offset, int whence) Zero(SvPVX(s->var) + oldcur, newlen - oldcur, char); /* No SvCUR_set(), though. This is just a seek, not a write. */ } + else if (!SvPVX(s->var)) { + /* ensure there's always a character buffer */ + (void)SvGROW(s->var,1); + } SvPOK_on(s->var); return 0; }