diff options
| author | John Hawthorn <john@hawthorn.email> | 2025-10-02 17:47:38 -0700 |
|---|---|---|
| committer | John Hawthorn <john@hawthorn.email> | 2025-10-03 10:30:14 -0700 |
| commit | 8eaa9eb3eb287063f8e004ecf4d12225214cda42 (patch) | |
| tree | 85226b3fb3669562ceb989f2a8c3ad900b921995 | |
| parent | 14cdd88970a2f1ec07bf97a5de50a47f4f6e7e4f (diff) | |
Clear fields on heap RStruct before allocating
Now that we no longer explicitly set the first three elements, we need
to ensure the object is in a state safe for GC before we call
struct_heap_alloc, which may GC.
| -rw-r--r-- | struct.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -834,10 +834,13 @@ struct_alloc(VALUE klass) else { NEWOBJ_OF(st, struct RStruct, klass, flags, sizeof(struct RStruct), 0); + st->as.heap.ptr = NULL; + st->as.heap.fields_obj = 0; + st->as.heap.len = 0; + st->as.heap.ptr = struct_heap_alloc((VALUE)st, n); rb_mem_clear((VALUE *)st->as.heap.ptr, n); st->as.heap.len = n; - st->as.heap.fields_obj = 0; return (VALUE)st; } |
