diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-17 11:42:08 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-03-17 11:42:08 +0000 |
commit | 2948dc26bd11d287cf72e407d0e5275b11b1ff82 (patch) | |
tree | 45f4215d7ae90fd444f4928f44798e67db5d139e /compile.c | |
parent | aa3b5b14e94851ab2ca598faf183048129f39ace (diff) |
compile.c: resize to align offsets
* compile.c (ibf_dump_align): resize the dump buffer.
rb_str_modify_expand expands the buffer but not set the length.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -8204,7 +8204,13 @@ ibf_dump_align(struct ibf_dump *dump, size_t align) { ibf_offset_t pos = ibf_dump_pos(dump); if (pos % align) { - rb_str_modify_expand(dump->str, align - (pos % align)); + long size = (long)pos - (pos % align) + align; +#if SIZEOF_LONG > SIZEOF_INT + if (pos >= UINT_MAX) { + rb_raise(rb_eRuntimeError, "dump size exceeds"); + } +#endif + rb_str_resize(dump->str, size); } } @@ -9553,6 +9559,10 @@ iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt) static const ibf_offset_t * ibf_iseq_list(const struct ibf_load *load) { + if (load->header->iseq_list_offset % sizeof(ibf_offset_t)) { + rb_raise(rb_eArgError, "unaligned iseq list offset: %u", + load->header->iseq_list_offset); + } return (ibf_offset_t *)(load->buff + load->header->iseq_list_offset); } |