diff --git a/ruby/ext/google/protobuf_c/protobuf.c b/ruby/ext/google/protobuf_c/protobuf.c index c27f30aa2d..c9eecee11e 100644 --- a/ruby/ext/google/protobuf_c/protobuf.c +++ b/ruby/ext/google/protobuf_c/protobuf.c @@ -37,7 +37,7 @@ #include "message.h" #include "repeated_field.h" -VALUE cError; +VALUE cParseError; VALUE cTypeError; const upb_fielddef* map_field_key(const upb_fielddef* field) { @@ -368,8 +368,10 @@ void Init_protobuf_c() { Map_register(protobuf); Message_register(protobuf); - cError = rb_const_get(protobuf, rb_intern("Error")); + cParseError = rb_const_get(protobuf, rb_intern("ParseError")); + rb_gc_register_mark_object(cParseError); cTypeError = rb_const_get(protobuf, rb_intern("TypeError")); + rb_gc_register_mark_object(cTypeError); rb_define_singleton_method(protobuf, "discard_unknown", Google_Protobuf_discard_unknown, 1);