google-protobuf 3.15.0-universal-darwin → 3.15.1-universal-darwin

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: c1c93443dc69dd5d213fe57808799dc537640e16bcd76a8b3ba267659369ce36
4
- data.tar.gz: ba1159f5396b4d599b112cc98318e2b55331828b11c1ea0c81654f38dfc614f6
3
+ metadata.gz: 71dbaada367023535dc1876c276c2e03e1585417df2bddeeb3dfee784351f03d
4
+ data.tar.gz: a28c3199e14075cee756d87f0440658cb211105fc6a47fc55f834757bc52e74f
5
5
  SHA512:
6
- metadata.gz: 42547d98098e841cc62d429f09de5f00a9b8acd05ba695ff9efa540364abdd8c312d760106a3533aac5ca57ea52917cf594c6ddb5f05bf8229df71e3c9539f72
7
- data.tar.gz: 36feb9a133bc5fdc1993ee9ce4bae948bdb41225b247b34c69826e07c950cd41799ed74de909ada81ea21e053e0e4dbe319effd93ce81a4f8a79d57d9ffc8224
6
+ metadata.gz: d90e399adc1e5edee7221248c01e30c4dadf23fc8733842c384bf24c162a76224f3d95b167b71d320e5354798e81c16ef5ff3501b98444fd4fead4842224ccb5
7
+ data.tar.gz: 1adb9bcc8688683c2c149458fb362026b68f08eda73b57228af351aea17977470b810185ae487184ba9dc4e1eaf5686927293423d8690ec5f770cf42bfffeadd
@@ -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: universal-darwin
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: