summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorksss <[email protected]>2017-05-27 13:29:38 +0900
committerksss <[email protected]>2017-05-27 13:34:11 +0900
commita3a4f4d061ed4fc1debbee0fe172a786c7c152d5 (patch)
treeeab3f3fe0b03cef0e9db381fbef3c732b4baa565 /src
parent0c0b34136e17b2452e3122f22813ca71d75434fd (diff)
downloadmruby-a3a4f4d061ed4fc1debbee0fe172a786c7c152d5.tar.gz
mruby-a3a4f4d061ed4fc1debbee0fe172a786c7c152d5.zip
IO#sysread Check for readable
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 */