diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-08 11:12:17 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-08 11:12:17 +0000 |
commit | fda1837e4923d1c8f9a5e3d69a70c3778a3cf9c6 (patch) | |
tree | 6331eec2a5f9a49c305980048ee8f3e27e91cfd1 /compile.c | |
parent | a72a50b15c60dbc33353d32a85555024b14e2494 (diff) |
compile.c: fix an exception argument
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -9487,6 +9487,7 @@ ibf_load_object(const struct ibf_load *load, VALUE object_index) ibf_offset_t *offsets = (ibf_offset_t *)(load->header->object_list_offset + load->buff); ibf_offset_t offset = offsets[object_index]; const struct ibf_object_header *header = IBF_OBJHEADER(offset); + size_t value_offset; #if IBF_ISEQ_DEBUG fprintf(stderr, "ibf_load_object: list=%#x offsets=%p offset=%#x\n", @@ -9494,10 +9495,11 @@ ibf_load_object(const struct ibf_load *load, VALUE object_index) fprintf(stderr, "ibf_load_object: type=%#x special=%d frozen=%d internal=%d\n", header->type, header->special_const, header->frozen, header->internal); #endif - if ((const char *)(header + 1) - load->buff >= RSTRING_LEN(load->str)) { - rb_raise(rb_eIndexError, "object offset out of range: %"PRIdSIZE, offset); - } - offset = (ibf_offset_t)((const char *)(header + 1) - load->buff); + value_offset = (const char *)(header + 1) - load->buff; + if (value_offset >= (size_t)RSTRING_LEN(load->str)) { + rb_raise(rb_eIndexError, "object offset out of range: %"PRIdSIZE, value_offset); + } + offset = (ibf_offset_t)value_offset; if (header->special_const) { const VALUE *vp = IBF_OBJBODY(VALUE, offset); |