This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
check ferror() only if read() returned 0
[perl5.git] / pp_sys.c
index fe75220..f880719 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1329,7 +1329,7 @@ PP(pp_sysread)
     {
        length = PerlIO_read(IoIFP(io), buffer+offset, length);
        /* fread() returns 0 on both error and EOF */
-       if (PerlIO_error(IoIFP(io)))
+       if (length == 0 && PerlIO_error(IoIFP(io)))
            length = -1;
     }
     if (length < 0)