mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
4a7bf2efe7
commit
04dfc46ad0
1 changed files with 7 additions and 3 deletions
10
compile.c
10
compile.c
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue