Skip to content

Commit 3e3407a

Browse files
committed
Re-add memset() that seemed redundant but is necessary in case of GC.
1 parent b9131f0 commit 3e3407a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

ruby/ext/google/protobuf_c/message.c

+3
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ VALUE Message_alloc(VALUE klass) {
7070
msg = (MessageHeader*)ALLOC_N(uint8_t,
7171
sizeof(MessageHeader) + desc->layout->size);
7272

73+
// Required in case a GC happens before layout_init().
74+
memset(msg, 0, desc->layout->size);
75+
7376
// We wrap first so that everything in the message object is GC-rooted in case
7477
// a collection happens during object creation in layout_init().
7578
ret = TypedData_Wrap_Struct(klass, &Message_type, msg);

0 commit comments

Comments
 (0)