diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-05 07:00:08 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-05 07:00:08 +0000 |
commit | 04dfc46ad0918964260d095b8f58e35eff5a33af (patch) | |
tree | 1ac3f29bf25ca0fa225f813e1e30530495cb34a9 /compile.c | |
parent | 4a7bf2efe702b64183259828de470d14df0f0031 (diff) | |
download | ruby-04dfc46ad0918964260d095b8f58e35eff5a33af.tar.gz |
compile.c: zero fill
* compile.c (ibf_dump_align): fill padding with zero, instead of
resizing only, not to leave garbages.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'compile.c')
-rw-r--r-- | compile.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -8231,13 +8231,17 @@ ibf_dump_align(struct ibf_dump *dump, size_t align) { ibf_offset_t pos = ibf_dump_pos(dump); if (pos % align) { - long size = (long)pos - (pos % align) + align; + static const char padding[sizeof(VALUE)]; + size_t size = align - ((size_t)pos % align); #if SIZEOF_LONG > SIZEOF_INT - if (pos >= UINT_MAX) { + if (pos + size >= UINT_MAX) { rb_raise(rb_eRuntimeError, "dump size exceeds"); } #endif - rb_str_resize(dump->str, size); + for (; size > sizeof(padding); size -= sizeof(padding)) { + rb_str_cat(dump->str, padding, sizeof(padding)); + } + rb_str_cat(dump->str, padding, size); } } |