google-protobuf 3.0.0 → 3.0.2

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
  SHA1:
3
- metadata.gz: ac3900d964acb20e8e5f6df229e0dbe61ae77a9d
4
- data.tar.gz: 87270390edfbd6291cda722b6859f0568481b64f
3
+ metadata.gz: 0b98a683cd2ee209e6fd5d830efa0a6ac489f42b
4
+ data.tar.gz: ae9803afe50cc1fdcbead860b0521298676b4ac9
5
5
  SHA512:
6
- metadata.gz: 0a1e3401b450988fa62b04c2e9fffff04748b6af355d66fa581913e64d3671c4dbc0b2974545faaf29bb1e92e33ca416b2a5a0eb85594fc7188eca12190f0ca1
7
- data.tar.gz: 284d85e88f0aba28c7c9fde75dd91f5ad9ab791e7f16069a6875cff2655c5ef89af5acfccf56c4355a0659df68fb19f049ab8dc2fd947a0b4289e0e8b60f5d9c
6
+ metadata.gz: a4997c0cd2a805e05861cc7bdcfb1d0dc3d0c883340f61eff661d649486ba8317662eeab62b7985ddbb1624955d8b6b3225ea6cd8fc0c212de1af05d7911a753
7
+ data.tar.gz: 05b45a6f7e35dee8bda810bc49a7b1799000a728f61e49f556b55f677dcb48a40554ab0d51c65ff49a339cda5f2adb03ddecce63f163a6f0286582f0d38771ae
@@ -255,10 +255,54 @@ typedef struct {
255
255
  // value into the map.
256
256
  typedef struct {
257
257
  VALUE map;
258
+ const map_handlerdata_t* handlerdata;
258
259
  char key_storage[NATIVE_SLOT_MAX_SIZE];
259
260
  char value_storage[NATIVE_SLOT_MAX_SIZE];
260
261
  } map_parse_frame_t;
261
262
 
263
+ static void MapParseFrame_mark(void* _self) {
264
+ map_parse_frame_t* frame = _self;
265
+
266
+ // This shouldn't strictly be necessary since this should be rooted by the
267
+ // message itself, but it can't hurt.
268
+ rb_gc_mark(frame->map);
269
+
270
+ native_slot_mark(frame->handlerdata->key_field_type, &frame->key_storage);
271
+ native_slot_mark(frame->handlerdata->value_field_type, &frame->value_storage);
272
+ }
273
+
274
+ void MapParseFrame_free(void* self) {
275
+ xfree(self);
276
+ }
277
+
278
+ rb_data_type_t MapParseFrame_type = {
279
+ "MapParseFrame",
280
+ { MapParseFrame_mark, MapParseFrame_free, NULL },
281
+ };
282
+
283
+ // Array of Ruby objects wrapping map_parse_frame_t.
284
+ // We don't allow multiple concurrent decodes, so we assume that this global
285
+ // variable is specific to the "current" decode.
286
+ VALUE map_parse_frames;
287
+
288
+ static map_parse_frame_t* map_push_frame(VALUE map,
289
+ const map_handlerdata_t* handlerdata) {
290
+ map_parse_frame_t* frame = ALLOC(map_parse_frame_t);
291
+ frame->handlerdata = handlerdata;
292
+ frame->map = map;
293
+ native_slot_init(handlerdata->key_field_type, &frame->key_storage);
294
+ native_slot_init(handlerdata->value_field_type, &frame->value_storage);
295
+
296
+ rb_ary_push(map_parse_frames,
297
+ TypedData_Wrap_Struct(rb_cObject, &MapParseFrame_type, frame));
298
+
299
+ return frame;
300
+ }
301
+
302
+ static void map_pop_frame() {
303
+ rb_ary_pop(map_parse_frames);
304
+ }
305
+
262
306
  // Handler to begin a map entry: allocates a temporary frame. This is the
263
307
  // 'startsubmsg' handler on the msgdef that contains the map field.
264
308
  static void *startmapentry_handler(void *closure, const void *hd) {
@@ -266,13 +310,7 @@ static void *startmapentry_handler(void *closure, const void *hd) {
266
310
  const map_handlerdata_t* mapdata = hd;
267
311
  VALUE map_rb = DEREF(msg, mapdata->ofs, VALUE);
268
312
 
269
- map_parse_frame_t* frame = ALLOC(map_parse_frame_t);
270
- frame->map = map_rb;
271
-
272
- native_slot_init(mapdata->key_field_type, &frame->key_storage);
273
- native_slot_init(mapdata->value_field_type, &frame->value_storage);
274
-
275
- return frame;
313
+ return map_push_frame(map_rb, mapdata);
276
314
  }
277
315
 
278
316
  // Handler to end a map entry: inserts the value defined during the message into
@@ -298,7 +336,7 @@ static bool endmap_handler(void *closure, const void *hd, upb_status* s) {
298
336
  &frame->value_storage);
299
337
 
300
338
  Map_index_set(frame->map, key, value);
301
- xfree(frame);
339
+ map_pop_frame();
302
340
 
303
341
  return true;
304
342
  }
@@ -737,6 +775,10 @@ VALUE Message_decode(VALUE klass, VALUE data) {
737
775
  msg_rb = rb_class_new_instance(0, NULL, msgklass);
738
776
  TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
739
777
 
778
+ // We generally expect this to be clear already, but clear it in case parsing
779
+ // previously got interrupted somehow.
780
+ rb_ary_clear(map_parse_frames);
781
+
740
782
  {
741
783
  const upb_pbdecodermethod* method = msgdef_decodermethod(desc);
742
784
  const upb_handlers* h = upb_pbdecodermethod_desthandlers(method);
@@ -781,6 +823,10 @@ VALUE Message_decode_json(VALUE klass, VALUE data) {
781
823
  msg_rb = rb_class_new_instance(0, NULL, msgklass);
782
824
  TypedData_Get_Struct(msg_rb, MessageHeader, &Message_type, msg);
783
825
 
826
+ // We generally expect this to be clear already, but clear it in case parsing
827
+ // previously got interrupted somehow.
828
+ rb_ary_clear(map_parse_frames);
829
+
784
830
  {
785
831
  const upb_json_parsermethod* method = msgdef_jsonparsermethod(desc);
786
832
  stackenv se;
@@ -112,4 +112,6 @@ void Init_protobuf_c() {
112
112
 
113
113
  upb_def_to_ruby_obj_map = rb_hash_new();
114
114
  rb_gc_register_address(&upb_def_to_ruby_obj_map);
115
+ map_parse_frames = rb_ary_new();
116
+ rb_gc_register_address(&map_parse_frames);
115
117
  }
@@ -166,6 +166,8 @@ extern VALUE cBuilder;
166
166
  extern VALUE cError;
167
167
  extern VALUE cParseError;
168
168
 
169
+ extern VALUE map_parse_frames;
170
+
169
171
  // We forward-declare all of the Ruby method implementations here because we
170
172
  // sometimes call the methods directly across .c files, rather than going
171
173
  // through Ruby's method dispatching (e.g. during message parse). It's cleaner
@@ -11175,7 +11175,7 @@ static bool parse_mapentry_key(upb_json_parser *p) {
11175
11175
  sel = getsel_for_handlertype(p, UPB_HANDLER_STRING);
11176
11176
  upb_sink_putstring(&subsink, sel, buf, len, NULL);
11177
11177
  sel = getsel_for_handlertype(p, UPB_HANDLER_ENDSTR);
11178
- upb_sink_endstr(&subsink, sel);
11178
+ upb_sink_endstr(&p->top->sink, sel);
11179
11179
  multipart_end(p);
11180
11180
  break;
11181
11181
  }
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.0.0
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Protobuf Authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-29 00:00:00.000000000 Z
11
+ date: 2016-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler-dock