Skip to content

Commit 04dfc46

Browse files
committed
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
1 parent 4a7bf2e commit 04dfc46

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compile.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8231,13 +8231,17 @@ ibf_dump_align(struct ibf_dump *dump, size_t align)
82318231
{
82328232
ibf_offset_t pos = ibf_dump_pos(dump);
82338233
if (pos % align) {
8234-
long size = (long)pos - (pos % align) + align;
8234+
static const char padding[sizeof(VALUE)];
8235+
size_t size = align - ((size_t)pos % align);
82358236
#if SIZEOF_LONG > SIZEOF_INT
8236-
if (pos >= UINT_MAX) {
8237+
if (pos + size >= UINT_MAX) {
82378238
rb_raise(rb_eRuntimeError, "dump size exceeds");
82388239
}
82398240
#endif
8240-
rb_str_resize(dump->str, size);
8241+
for (; size > sizeof(padding); size -= sizeof(padding)) {
8242+
rb_str_cat(dump->str, padding, sizeof(padding));
8243+
}
8244+
rb_str_cat(dump->str, padding, size);
82418245
}
82428246
}
82438247

0 commit comments

Comments
 (0)