This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix bug #40407: after a seek on a PerlIO::scalar filehandle,
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 11 Jan 2007 10:34:02 +0000 (10:34 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 11 Jan 2007 10:34:02 +0000 (10:34 +0000)
ensure there's a string buffer in the scalar

p4raw-id: //depot/perl@29751

ext/PerlIO/scalar/scalar.xs

index 319c851..b31e681 100644 (file)
@@ -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;
 }