diff options
| author | KOBAYASHI Shuji <[email protected]> | 2020-12-15 17:48:06 +0900 |
|---|---|---|
| committer | KOBAYASHI Shuji <[email protected]> | 2020-12-15 17:48:06 +0900 |
| commit | d5cb54d4df298d11158f8ff684845182dda0e3f7 (patch) | |
| tree | 9aff4d2a0d0ad5c50c930834be632b00f6d7c2b4 /src/gc.c | |
| parent | e9fe337b952731226449027a4c34471af27b23e6 (diff) | |
| download | mruby-d5cb54d4df298d11158f8ff684845182dda0e3f7.tar.gz mruby-d5cb54d4df298d11158f8ff684845182dda0e3f7.zip | |
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.
Diffstat (limited to 'src/gc.c')
| -rw-r--r-- | src/gc.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; |
