google-protobuf 3.15.0-x86-mingw32 → 3.15.1-x86-mingw32

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: 76f0a3578ecf8a5c374306ec7ae640241270522ccb352c9399c16f45ce0f8033
4
- data.tar.gz: 7c82aab5a418dd2d81250bc14443f7c8d81d3ad76256cd314456b7f244d622c9
3
+ metadata.gz: ec5c815076282cb80c611d9a32c6bfbc406405bcdedc063e394dca56545ac0bf
4
+ data.tar.gz: b68e07f6c65893abb0d496b6736a36b05e5804c34bf2b8d3659bf5d6fa071ab7
5
5
  SHA512:
6
- metadata.gz: 93b4066b920421a632af348e5644351eb2bc60a756cdb956462a2008089687864b1c51395ebf1fb920bf8d63e4b546dd39225e52fc2967d0f7c2e4c8b9334d84
7
- data.tar.gz: a28dd67a9382d1eced49ff13d81e97f3d5d9d4e08d631e7e20ad7893d5c1fe0f16ab2a717926b31655afb1ec69651d7521e521d03f6a743f8e2eb9ae7940739c
6
+ metadata.gz: c25affa9ea57491645b6484738e907e38e1e26f0b001ad3afe2d778b17134c51e0ab532cef055cdb8625d1767d1c01768e5d368f36a9c2993fde582cff28a878
7
+ data.tar.gz: a05e850981681b09e0a658fee23e175c03afbe5031e0a4e96a95155f2f35f8ac60b2861fd3a8fb75057673889f4f349da6961168b1c3c0dd68924d58af3ac615
@@ -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-mingw32
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: