From d5cb54d4df298d11158f8ff684845182dda0e3f7 Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Tue, 15 Dec 2020 17:48:06 +0900 Subject: 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. --- src/gc.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/gc.c b/src/gc.c index 83454fa5c..85c22caad 100644 --- a/src/gc.c +++ b/src/gc.c @@ -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; -- cgit v1.2.3