aboutsummaryrefslogtreecommitdiffstats
path: root/compile.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-17 11:42:08 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-17 11:42:08 +0000
commit03c4df9b643802452b2da9c5e4c5deeb61fa8ae1 (patch)
tree45f4215d7ae90fd444f4928f44798e67db5d139e /compile.c
parent7320a37c6abb45632209d67e37ea1cfd778cc116 (diff)
downloadruby-03c4df9b643802452b2da9c5e4c5deeb61fa8ae1.tar.gz
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.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/compile.c b/compile.c
index 884f06c2a1..b90ff792ad 100644
--- a/compile.c
+++ b/compile.c
@@ -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);
}