mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Ensure initialization of RVALUE_zero in mrb_obj_alloc
Union initialization initializes the first member. The first member of `RVALUE` is `struct free_obj`, but because it is only 4-words, it seems that initialization after the 5th word is not ensured. Therefore, I created 6-words `struct RVALUE_initializer` for initialization and made it the first member.
This commit is contained in:
@@ -107,8 +107,14 @@ struct free_obj {
|
||||
struct RBasic *next;
|
||||
};
|
||||
|
||||
struct RVALUE_initializer {
|
||||
MRB_OBJECT_HEADER;
|
||||
char padding[sizeof(void*) * 4 - sizeof(uint32_t)];
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
struct RVALUE_initializer init; /* must be first member to ensure initialization */
|
||||
struct free_obj free;
|
||||
struct RBasic basic;
|
||||
struct RObject object;
|
||||
|
||||
Reference in New Issue
Block a user