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:
KOBAYASHI Shuji
2020-12-15 17:48:06 +09:00
parent e9fe337b95
commit d5cb54d4df
+6
View File
@@ -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;