diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2017-11-29 10:07:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-29 10:07:35 -0800 |
commit | 0289dd8f90b79ad3d2376aadec4538f9ac8b0417 (patch) | |
tree | d22f9dea47dfaeaee132ffdc70125095143a899f /ruby/ext/google/protobuf_c/storage.c | |
parent | 74f64b667cc558cdc6318275d640e742e7f9cd8b (diff) | |
parent | 1e58006b3cca28d11bbc92074c10b3295330b2b9 (diff) | |
download | protobuf-0289dd8f90b79ad3d2376aadec4538f9ac8b0417.tar.gz protobuf-0289dd8f90b79ad3d2376aadec4538f9ac8b0417.tar.bz2 protobuf-0289dd8f90b79ad3d2376aadec4538f9ac8b0417.zip |
Merge pull request #2519 from rubynerd-forks/ruby-fix-repeated-message-type-field
unwrap descriptor class before comparison of RepeatedField types
Diffstat (limited to 'ruby/ext/google/protobuf_c/storage.c')
-rw-r--r-- | ruby/ext/google/protobuf_c/storage.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ruby/ext/google/protobuf_c/storage.c b/ruby/ext/google/protobuf_c/storage.c index 24064dfd..1437c0b5 100644 --- a/ruby/ext/google/protobuf_c/storage.c +++ b/ruby/ext/google/protobuf_c/storage.c @@ -606,12 +606,20 @@ static void check_repeated_field_type(VALUE val, const upb_fielddef* field) { rb_raise(rb_eTypeError, "Repeated field array has wrong element type"); } - if (self->field_type == UPB_TYPE_MESSAGE || - self->field_type == UPB_TYPE_ENUM) { + if (self->field_type == UPB_TYPE_MESSAGE) { if (self->field_type_class != - get_def_obj(upb_fielddef_subdef(field))) { + Descriptor_msgclass(get_def_obj(upb_fielddef_subdef(field)))) { rb_raise(rb_eTypeError, - "Repeated field array has wrong message/enum class"); + "Repeated field array has wrong message class"); + } + } + + + if (self->field_type == UPB_TYPE_ENUM) { + if (self->field_type_class != + EnumDescriptor_enummodule(get_def_obj(upb_fielddef_subdef(field)))) { + rb_raise(rb_eTypeError, + "Repeated field array has wrong enum class"); } } } |