summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/io.c b/io.c
index 2f47e5f818..4865b7ce79 100644
--- a/io.c
+++ b/io.c
@@ -710,8 +710,10 @@ rb_io_fread(ptr, len, f)
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
- clearerr(f);
- return len - n;
+ if (len - n > 0) {
+ clearerr(f);
+ return len - n;
+ }
}
return 0;
}