Skip to content

Commit

Permalink
Validate size and serialized
Browse files Browse the repository at this point in the history
To investigate the error on CI.
  • Loading branch information
y-yagi committed Jan 26, 2025
1 parent a35588e commit 51e54e3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ruby/ext/google/protobuf_c/defs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,14 @@ static VALUE EnumDescriptor_to_proto(VALUE _self) {
proto, arena, &size);

upb_Arena_Free(arena);

if (size == 0) {
rb_raise(rb_eRuntimeError, "Internal error, size should not be zero");
}
if (serialized == NULL) {
rb_raise(rb_eRuntimeError, "Internal error, cannot serialize proto");
}

VALUE proto_class = rb_path2class("Google::Protobuf::EnumDescriptorProto");
return Message_decode_bytes(size, serialized, 0, proto_class, false);
}
Expand Down

0 comments on commit 51e54e3

Please sign in to comment.