Test offset when reading from a PerlIO::Scalar
Benjamin Sugars [Tue, 8 May 2001 17:09:44 +0000 (13:09 -0400)]
Message-ID: <Pine.LNX.4.21.0105081654140.1212-100000@marmot.rim.canoe.ca>

p4raw-id: //depot/perl@10053

ext/PerlIO/Scalar/Scalar.xs

index a4203bf..e1e9349 100644 (file)
@@ -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;
 }