summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/io.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/io.c b/src/io.c
index 6d1b39cc5..e0de0ca36 100644
--- a/src/io.c
+++ b/src/io.c
@@ -637,6 +637,9 @@ mrb_io_sysread(mrb_state *mrb, mrb_value io)
}
fptr = (struct mrb_io *)io_get_open_fptr(mrb, io);
+ if (!fptr->readable) {
+ mrb_raise(mrb, E_IO_ERROR, "not opened for reading");
+ }
ret = read(fptr->fd, RSTRING_PTR(buf), maxlen);
switch (ret) {
case 0: /* EOF */