summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/io.c b/io.c
index 3aa95e2cae..c1c7d511db 100644
--- a/io.c
+++ b/io.c
@@ -449,14 +449,15 @@ io_fread(ptr, len, f)
FILE *f;
{
size_t n = len;
+ int c;
while (n--) {
- *ptr = getc(f);
- if (*ptr == EOF) {
+ c = getc(f);
+ if (c == EOF) {
*ptr = '\0';
break;
}
- ptr++;
+ *ptr++ = c;
if (!READ_DATA_PENDING(f)) {
rb_thread_wait_fd(fileno(f));
}