diff options
author | @rubynerd <x@rubynerd.net> | 2016-12-30 02:26:25 +0000 |
---|---|---|
committer | @rubynerd <x@rubynerd.net> | 2016-12-30 02:26:25 +0000 |
commit | f3e86fd26a685dd235e9a4849f62115e1348e91b (patch) | |
tree | de866f55a80c2b396a7e9eebfaf2ffe3a0344ba8 /ruby/ext/google/protobuf_c | |
parent | c64830bbca7ce327ad38e51ea4ddf96328804604 (diff) | |
download | protobuf-f3e86fd26a685dd235e9a4849f62115e1348e91b.tar.gz protobuf-f3e86fd26a685dd235e9a4849f62115e1348e91b.tar.bz2 protobuf-f3e86fd26a685dd235e9a4849f62115e1348e91b.zip |
handle sanity check for repeating enums correctly
Diffstat (limited to 'ruby/ext/google/protobuf_c')
-rw-r--r-- | ruby/ext/google/protobuf_c/storage.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/ruby/ext/google/protobuf_c/storage.c b/ruby/ext/google/protobuf_c/storage.c index 8e474244..fa2e0257 100644 --- a/ruby/ext/google/protobuf_c/storage.c +++ b/ruby/ext/google/protobuf_c/storage.c @@ -595,12 +595,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 != 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"); } } } |