summaryrefslogtreecommitdiff
path: root/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/marshal.c b/marshal.c
index 9bed429..94a2eb5 100644
--- a/marshal.c
+++ b/marshal.c
@@ -712,11 +712,14 @@ r_bytes0(s, len, arg)
struct load_arg *arg;
{
if (arg->fp) {
- len = fread(s, 1, len, arg->fp);
+ if (rb_io_fread(s, len, arg->fp) != len) {
+ too_short:
+ rb_raise(rb_eArgError, "marshal data too short");
+ }
}
else {
if (arg->ptr + len > arg->end) {
- len = arg->end - arg->ptr;
+ goto too_short;
}
memcpy(s, arg->ptr, len);
arg->ptr += len;