google-protobuf 3.15.0-x86-linux → 3.15.1-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of google-protobuf might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a15a7b617cdcc934844b0424af5d3234df662537a4a2fb8ec9f18f1483cb0e4
4
- data.tar.gz: acf7191104aae336c74324cd5b3696315b5a8eca3394eefdda934290eed88f10
3
+ metadata.gz: 5497747cb5d41a80d468266aba3df5ea5a7fc4437813370988ec2730bbb87dfa
4
+ data.tar.gz: e257b0de5478e0806b5ba5c813ddb7bc89a68ea2a48bf72d48237c48e9badccb
5
5
  SHA512:
6
- metadata.gz: '09bf0a320f79f8fba7cff6c09f688332da4f25b8faf45dd9000f3d106f16d8e9c5a091efc64d67ba16d83ea9e6004a94e4779575a8ed037f60fca1aa517c00af'
7
- data.tar.gz: 35497ca99d838ff6068847c5eaad4b12fb64f67bb834623ac92eb9a0c54cb7964b9740491d7070d921a65351ccf300ed3db3a7caefa9cf86986f7fe6d5e4137f
6
+ metadata.gz: c54bf272e54ca1e866e30cccf2c45975abf55f1778499a8e6578f77efa5202bedd19db8e2ea0a874d1c79c371eba029ae2b407807dd8570e12e00c5cb8029fd6
7
+ data.tar.gz: c9509f10d8171754f2c0b74a6f9bea95e64be3cb5aab128b6d092a4f678785b3a5768fc5db65ec4edb87ab4057d9f95b2a4855ee35316ce7330cf97375a04eeb
@@ -292,6 +292,35 @@ static void Message_setfield(upb_msg* msg, const upb_fielddef* f, VALUE val,
292
292
  upb_msg_set(msg, f, msgval, arena);
293
293
  }
294
294
 
295
+ static VALUE Message_getfield(VALUE _self, const upb_fielddef* f) {
296
+ Message* self = ruby_to_Message(_self);
297
+ // This is a special-case: upb_msg_mutable() for map & array are logically
298
+ // const (they will not change what is serialized) but physically
299
+ // non-const, as they do allocate a repeated field or map. The logical
300
+ // constness means it's ok to do even if the message is frozen.
301
+ upb_msg *msg = (upb_msg*)self->msg;
302
+ upb_arena *arena = Arena_get(self->arena);
303
+ if (upb_fielddef_ismap(f)) {
304
+ upb_map *map = upb_msg_mutable(msg, f, arena).map;
305
+ const upb_fielddef *key_f = map_field_key(f);
306
+ const upb_fielddef *val_f = map_field_value(f);
307
+ upb_fieldtype_t key_type = upb_fielddef_type(key_f);
308
+ TypeInfo value_type_info = TypeInfo_get(val_f);
309
+ return Map_GetRubyWrapper(map, key_type, value_type_info, self->arena);
310
+ } else if (upb_fielddef_isseq(f)) {
311
+ upb_array *arr = upb_msg_mutable(msg, f, arena).array;
312
+ return RepeatedField_GetRubyWrapper(arr, TypeInfo_get(f), self->arena);
313
+ } else if (upb_fielddef_issubmsg(f)) {
314
+ if (!upb_msg_has(self->msg, f)) return Qnil;
315
+ upb_msg *submsg = upb_msg_mutable(msg, f, arena).msg;
316
+ const upb_msgdef *m = upb_fielddef_msgsubdef(f);
317
+ return Message_GetRubyWrapper(submsg, m, self->arena);
318
+ } else {
319
+ upb_msgval msgval = upb_msg_get(self->msg, f);
320
+ return Convert_UpbToRuby(msgval, TypeInfo_get(f), self->arena);
321
+ }
322
+ }
323
+
295
324
  static VALUE Message_field_accessor(VALUE _self, const upb_fielddef* f,
296
325
  int accessor_type, int argc, VALUE* argv) {
297
326
  upb_arena *arena = Arena_get(Message_GetArena(_self));
@@ -350,36 +379,11 @@ static VALUE Message_field_accessor(VALUE _self, const upb_fielddef* f,
350
379
  return INT2NUM(msgval.int32_val);
351
380
  }
352
381
  }
353
- case METHOD_GETTER: {
354
- Message* self = ruby_to_Message(_self);
355
- // This is a special-case: upb_msg_mutable() for map & array are logically
356
- // const (they will not change what is serialized) but physically
357
- // non-const, as they do allocate a repeated field or map. The logical
358
- // constness means it's ok to do even if the message is frozen.
359
- upb_msg *msg = (upb_msg*)self->msg;
360
- if (upb_fielddef_ismap(f)) {
361
- upb_map *map = upb_msg_mutable(msg, f, arena).map;
362
- const upb_fielddef *key_f = map_field_key(f);
363
- const upb_fielddef *val_f = map_field_value(f);
364
- upb_fieldtype_t key_type = upb_fielddef_type(key_f);
365
- TypeInfo value_type_info = TypeInfo_get(val_f);
366
- return Map_GetRubyWrapper(map, key_type, value_type_info, self->arena);
367
- } else if (upb_fielddef_isseq(f)) {
368
- upb_array *arr = upb_msg_mutable(msg, f, arena).array;
369
- return RepeatedField_GetRubyWrapper(arr, TypeInfo_get(f), self->arena);
370
- } else if (upb_fielddef_issubmsg(f)) {
371
- if (!upb_msg_has(self->msg, f)) return Qnil;
372
- upb_msg *submsg = upb_msg_mutable(msg, f, arena).msg;
373
- const upb_msgdef *m = upb_fielddef_msgsubdef(f);
374
- return Message_GetRubyWrapper(submsg, m, self->arena);
375
- } else {
376
- upb_msgval msgval = upb_msg_get(self->msg, f);
377
- return Convert_UpbToRuby(msgval, TypeInfo_get(f), self->arena);
378
- }
382
+ case METHOD_GETTER:
383
+ return Message_getfield(_self, f);
379
384
  default:
380
385
  rb_raise(rb_eRuntimeError, "Internal error, no such accessor: %d",
381
386
  accessor_type);
382
- }
383
387
  }
384
388
  }
385
389
 
@@ -866,7 +870,6 @@ static VALUE Message_freeze(VALUE _self) {
866
870
  static VALUE Message_index(VALUE _self, VALUE field_name) {
867
871
  Message* self = ruby_to_Message(_self);
868
872
  const upb_fielddef* field;
869
- upb_msgval val;
870
873
 
871
874
  Check_Type(field_name, T_STRING);
872
875
  field = upb_msgdef_ntofz(self->msgdef, RSTRING_PTR(field_name));
@@ -875,8 +878,7 @@ static VALUE Message_index(VALUE _self, VALUE field_name) {
875
878
  return Qnil;
876
879
  }
877
880
 
878
- val = upb_msg_get(self->msg, field);
879
- return Convert_UpbToRuby(val, TypeInfo_get(field), self->arena);
881
+ return Message_getfield(_self, field);
880
882
  }
881
883
 
882
884
  /*
@@ -1285,7 +1287,7 @@ const upb_msg* Message_GetUpbMessage(VALUE value, const upb_msgdef* m,
1285
1287
  if (!rb_obj_is_kind_of(value, rb_cNumeric)) goto badtype;
1286
1288
 
1287
1289
  sec.int64_val = NUM2LL(value);
1288
- nsec.int32_val = (NUM2DBL(value) - NUM2LL(value)) * 1000000000;
1290
+ nsec.int32_val = round((NUM2DBL(value) - NUM2LL(value)) * 1000000000);
1289
1291
  upb_msg_set(msg, sec_f, sec, arena);
1290
1292
  upb_msg_set(msg, nsec_f, nsec, arena);
1291
1293
  return msg;
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/tests/basic.rb CHANGED
@@ -31,6 +31,33 @@ module BasicTest
31
31
  end
32
32
  include CommonTests
33
33
 
34
+ def test_issue_8311_crash
35
+ Google::Protobuf::DescriptorPool.generated_pool.build do
36
+ add_file("inner.proto", :syntax => :proto3) do
37
+ add_message "Inner" do
38
+ # Removing either of these fixes the segfault.
39
+ optional :foo, :string, 1
40
+ optional :bar, :string, 2
41
+ end
42
+ end
43
+ end
44
+
45
+ Google::Protobuf::DescriptorPool.generated_pool.build do
46
+ add_file("outer.proto", :syntax => :proto3) do
47
+ add_message "Outer" do
48
+ repeated :inners, :message, 1, "Inner"
49
+ end
50
+ end
51
+ end
52
+
53
+ outer = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Outer").msgclass
54
+
55
+ outer_proto = outer.new(
56
+ inners: []
57
+ )
58
+ outer_proto['inners'].to_s
59
+ end
60
+
34
61
  def test_has_field
35
62
  m = TestSingularFields.new
36
63
  assert !m.has_singular_msg?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-protobuf
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.15.0
4
+ version: 3.15.1
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-18 00:00:00.000000000 Z
11
+ date: 2021-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock
@@ -128,7 +128,7 @@ homepage: https://developers.google.com/protocol-buffers
128
128
  licenses:
129
129
  - BSD-3-Clause
130
130
  metadata:
131
- source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.15.0/ruby
131
+ source_code_uri: https://github.com/protocolbuffers/protobuf/tree/v3.15.1/ruby
132
132
  post_install_message:
133
133
  rdoc_options: []
134
134
  require_paths: