From: Benjamin Sugars Date: Tue, 8 May 2001 17:09:44 +0000 (-0400) Subject: Test offset when reading from a PerlIO::Scalar X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=75effbe0883c73e5d0f7c9626142eb85d956f1d3;p=p5sagit%2Fp5-mst-13.2.git Test offset when reading from a PerlIO::Scalar Message-ID: p4raw-id: //depot/perl@10053 --- diff --git a/ext/PerlIO/Scalar/Scalar.xs b/ext/PerlIO/Scalar/Scalar.xs index a4203bf..e1e9349 100644 --- a/ext/PerlIO/Scalar/Scalar.xs +++ b/ext/PerlIO/Scalar/Scalar.xs @@ -198,7 +198,10 @@ PerlIOScalar_get_cnt(PerlIO *f) if (PerlIOBase(f)->flags & PERLIO_F_CANREAD) { PerlIOScalar *s = PerlIOSelf(f,PerlIOScalar); - return SvCUR(s->var) - s->posn; + if (SvCUR(s->var) > s->posn) + return SvCUR(s->var) - s->posn; + else + return 0; } return 0; }