summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-27 23:12:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-27 23:12:43 +0000
commita9280ca7c91c38b5135ca63ae0bbdb669e589f28 (patch)
tree51b90607e1ceabef81263c5aba4ec7acffa5c7d3 /io.c
parent7567345876e063a9d65d259dcc86516a43be090c (diff)
* io.c (read_buffered_data): check if reached EOF. fixed: [ruby-dev:27334]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 24533a6e89..0d97b16e6a 100644
--- a/io.c
+++ b/io.c
@@ -1020,8 +1020,10 @@ read_buffered_data(ptr, len, f)
if (n > len) n = len;
return fread(ptr, 1, n, f);
#else
- for (n = 0; n < len && READ_DATA_PENDING(f); ++n) {
- *ptr++ = getc(f);
+ int c;
+
+ for (n = 0; n < len && READ_DATA_PENDING(f) && (c = getc(f)) != EOF; ++n) {
+ *ptr++ = c;
}
return n;
#endif