From 8b8eea963147e9111f99b4c1bf3eb8b60fe51935 Mon Sep 17 00:00:00 2001 From: Rafael Garcia-Suarez Date: Thu, 11 Jan 2007 10:34:02 +0000 Subject: [PATCH] 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 --- ext/PerlIO/scalar/scalar.xs | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- 2.7.4