8000 compile.c: clear padding · willnet/ruby@e9c2fe4 · GitHub
[go: up one dir, main page]

Skip to content

Commit e9c2fe4

Browse files
committed
compile.c: clear padding
* compile.c (IBF_ZERO): clear padding of struct not to include garbages in dumped binary data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent 6bcfa84 commit e9c2fe4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

compile.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8276,6 +8276,7 @@ ibf_load_alloc(const struct ibf_load *load, ibf_offset_t offset, int size)
82768276
#define IBF_WV(variable) ibf_dump_write(dump, &(variable), sizeof(variable))
82778277
#define IBF_WP(b, type, n) ibf_dump_write(dump, (b), sizeof(type) * (n))
82788278
#define IBF_R(val, type, n) (type *)ibf_load_alloc(load, IBF_OFFSET(val), sizeof(type) * (n))
8279+
#define IBF_ZERO(variable) memset(&(variable), 0, sizeof(variable))
82798280

82808281
static int
82818282
ibf_table_lookup(struct st_table *table, st_data_t key)
@@ -9121,6 +9122,7 @@ ibf_dump_object_regexp(struct ibf_dump *dump, VALUE obj)
91219122
{
91229123
struct ibf_object_regexp regexp;
91239124
VALUE srcstr = RREGEXP_SRC(obj);
9125+
IBF_ZERO(regexp);
91249126
regexp.option = (char)rb_reg_options(obj);
91259127
regexp.srcstr = (long)ibf_dump_object(dump, srcstr);
91269128
IBF_WV(regexp);
@@ -9212,6 +9214,7 @@ ibf_dump_object_struct(struct ibf_dump *dump, VALUE obj)
92129214
if (rb_obj_is_kind_of(obj, rb_cRange)) {
92139215
struct ibf_object_struct_range range;
92149216
VALUE beg, end;
9217+
IBF_ZERO(range);
92159218
range.len = 3;
92169219
range.class_index = 0;
92179220

@@ -9272,7 +9275,7 @@ ibf_dump_object_data(struct ibf_dump *dump, VALUE obj)
92729275
long len = strlen(name) + 1;
92739276
IBF_WV(type);
92749277
IBF_WV(len);
9275-
IBF_WP(name, char, strlen(name) + 1);
9278+
IBF_WP(name, char, len);
92769279
}
92779280
else {
92789281
ibf_dump_object_unsupported(dump, obj);
@@ -9380,6 +9383,7 @@ ibf_dump_object_object(struct ibf_dump *dump, VALUE obj)
93809383
{
93819384
struct ibf_object_header obj_header;
93829385
ibf_offset_t current_offset = ibf_dump_pos(dump);
9386+
IBF_ZERO(obj_header);
93839387
obj_header.type = TYPE(obj);
93849388

93859389
if (SPECIAL_CONST_P(obj)) {

0 commit comments

Comments
 (0)
0