msgpack 0.7.0-x64-mingw32 → 0.7.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43e496b54b8be99f64073aa2f5fb8130c7dfafc2
4
- data.tar.gz: 6191669fc93023acda5d3f39dfdd73ba3625c5e2
3
+ metadata.gz: b46f27dcec150475f835906b4189a10fc68df8ae
4
+ data.tar.gz: db691798ba819123902666b4bb4f7bbc4bc2147d
5
5
  SHA512:
6
- metadata.gz: b4e9b460ac9c391012adfb23a78baed25bc9920f9c23ad120df5c4342e0c1e4364be17d2ba0a2b1455f92fa42fb9e158ef9a8542eea83ff18a4c7dddc12028a4
7
- data.tar.gz: 18884c48774eb731332c186a40cb01f3bc401361fae93776355798a6444141415e9c81183d363a1f07f3203abf9e85ef8e068c5ee1bb46c3f35128f36d0cb1b3
6
+ metadata.gz: 890724483e007a8dc0f8b25e03372fea3ab890cf28d175fa675c27c5c6225dce97e8b69adfd8477fc694037621d52041b720418770373c1637fcee74b0782654
7
+ data.tar.gz: f32288661641e89d43d7afd65b7d868c3e85e850b9d92a3410459ef123be4a7114588120df9a75733b45ca12dc65e3f043d65ee97e13aa72446364028615e18c
data/.travis.yml CHANGED
@@ -13,6 +13,8 @@ os:
13
13
  - linux
14
14
  - osx
15
15
 
16
+ sudo: false
17
+
16
18
  branches:
17
19
  only:
18
20
  - master
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ 2015-11-20 version 0.7.1:
2
+
3
+ * Fixed bug to pack/unpack ext type objects larger than 256bytes incorrectly.
4
+
1
5
  2015-10-24 version 0.7.0:
2
6
 
3
7
  * Add extention types support.
data/doclib/msgpack.rb CHANGED
@@ -73,5 +73,15 @@ module MessagePack
73
73
  #
74
74
  def self.unpack(src, options={})
75
75
  end
76
+
77
+ #
78
+ # An instance of Factory class. DefaultFactory is also used
79
+ # by global pack/unpack methods such as MessagePack.dump/load,
80
+ # Hash#to_msgpack, and other to_msgpack methods.
81
+ #
82
+ # Calling DefaultFactory.register_type lets you add an extension
83
+ # type globally.
84
+ #
85
+ DefaultFactory = Factory.new
76
86
  end
77
87
 
@@ -236,8 +236,8 @@ public class Decoder implements Iterator<IRubyObject> {
236
236
  case BIN8: return consumeString(buffer.get() & 0xff, binaryEncoding);
237
237
  case BIN16: return consumeString(buffer.getShort() & 0xffff, binaryEncoding);
238
238
  case BIN32: return consumeString(buffer.getInt(), binaryEncoding);
239
- case VAREXT8: return consumeExtension(buffer.get());
240
- case VAREXT16: return consumeExtension(buffer.getShort());
239
+ case VAREXT8: return consumeExtension(buffer.get() & 0xff);
240
+ case VAREXT16: return consumeExtension(buffer.getShort() & 0xffff);
241
241
  case VAREXT32: return consumeExtension(buffer.getInt());
242
242
  case FLOAT32: return runtime.newFloat(buffer.getFloat());
243
243
  case FLOAT64: return runtime.newFloat(buffer.getDouble());
data/ext/msgpack/buffer.c CHANGED
@@ -74,13 +74,13 @@ static void _msgpack_buffer_chunk_destroy(msgpack_buffer_chunk_t* c)
74
74
  if(c->mem != NULL) {
75
75
  #ifndef DISABLE_RMEM
76
76
  if(!msgpack_rmem_free(&s_rmem, c->mem)) {
77
- free(c->mem);
77
+ xfree(c->mem);
78
78
  }
79
79
  /* no needs to update rmem_owner because chunks will not be
80
80
  * free()ed (left in free_list) and thus *rmem_owner is
81
81
  * always valid. */
82
82
  #else
83
- free(c->mem);
83
+ xfree(c->mem);
84
84
  #endif
85
85
  }
86
86
  c->first = NULL;
@@ -95,7 +95,7 @@ void msgpack_buffer_destroy(msgpack_buffer_t* b)
95
95
  while(c != &b->tail) {
96
96
  msgpack_buffer_chunk_t* n = c->next;
97
97
  _msgpack_buffer_chunk_destroy(c);
98
- free(c);
98
+ xfree(c);
99
99
  c = n;
100
100
  }
101
101
  _msgpack_buffer_chunk_destroy(c);
@@ -103,7 +103,7 @@ void msgpack_buffer_destroy(msgpack_buffer_t* b)
103
103
  c = b->free_list;
104
104
  while(c != NULL) {
105
105
  msgpack_buffer_chunk_t* n = c->next;
106
- free(c);
106
+ xfree(c);
107
107
  c = n;
108
108
  }
109
109
  }
@@ -259,7 +259,7 @@ static inline msgpack_buffer_chunk_t* _msgpack_buffer_alloc_new_chunk(msgpack_bu
259
259
  {
260
260
  msgpack_buffer_chunk_t* reuse = b->free_list;
261
261
  if(reuse == NULL) {
262
- return malloc(sizeof(msgpack_buffer_chunk_t));
262
+ return xmalloc(sizeof(msgpack_buffer_chunk_t));
263
263
  }
264
264
  b->free_list = b->free_list->next;
265
265
  return reuse;
@@ -403,7 +403,7 @@ static inline void* _msgpack_buffer_chunk_malloc(
403
403
 
404
404
  // TODO alignment?
405
405
  *allocated_size = required_size;
406
- void* mem = malloc(required_size);
406
+ void* mem = xmalloc(required_size);
407
407
  c->mem = mem;
408
408
  return mem;
409
409
  }
@@ -421,7 +421,7 @@ static inline void* _msgpack_buffer_chunk_realloc(
421
421
  next_size *= 2;
422
422
  }
423
423
  *current_size = next_size;
424
- mem = realloc(mem, next_size);
424
+ mem = xrealloc(mem, next_size);
425
425
 
426
426
  c->mem = mem;
427
427
  return mem;
@@ -49,7 +49,7 @@ static void Buffer_free(void* data)
49
49
  }
50
50
  msgpack_buffer_t* b = (msgpack_buffer_t*) data;
51
51
  msgpack_buffer_destroy(b);
52
- free(b);
52
+ xfree(b);
53
53
  }
54
54
 
55
55
  static VALUE Buffer_alloc(VALUE klass)
@@ -48,7 +48,7 @@ static void Factory_free(msgpack_factory_t* fc)
48
48
  }
49
49
  msgpack_packer_ext_registry_destroy(&fc->pkrg);
50
50
  msgpack_unpacker_ext_registry_destroy(&fc->ukrg);
51
- free(fc);
51
+ xfree(fc);
52
52
  }
53
53
 
54
54
  void Factory_mark(msgpack_factory_t* fc)
data/ext/msgpack/packer.h CHANGED
@@ -364,7 +364,7 @@ static inline void msgpack_packer_write_ext(msgpack_packer_t* pk, int ext_type,
364
364
  msgpack_buffer_write_2(PACKER_BUFFER_(pk), 0xd8, ext_type);
365
365
  break;
366
366
  default:
367
- if(len < 255) {
367
+ if(len < 256) {
368
368
  msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 3);
369
369
  msgpack_buffer_write_2(PACKER_BUFFER_(pk), 0xc7, len);
370
370
  msgpack_buffer_write_1(PACKER_BUFFER_(pk), ext_type);
@@ -45,7 +45,7 @@ static void Packer_free(msgpack_packer_t* pk)
45
45
  }
46
46
  msgpack_packer_ext_registry_destroy(&pk->ext_registry);
47
47
  msgpack_packer_destroy(pk);
48
- free(pk);
48
+ xfree(pk);
49
49
  }
50
50
 
51
51
  static void Packer_mark(msgpack_packer_t* pk)
data/ext/msgpack/rmem.c CHANGED
@@ -21,7 +21,7 @@
21
21
  void msgpack_rmem_init(msgpack_rmem_t* pm)
22
22
  {
23
23
  memset(pm, 0, sizeof(msgpack_rmem_t));
24
- pm->head.pages = malloc(MSGPACK_RMEM_PAGE_SIZE * 32);
24
+ pm->head.pages = xmalloc(MSGPACK_RMEM_PAGE_SIZE * 32);
25
25
  pm->head.mask = 0xffffffff; /* all bit is 1 = available */
26
26
  }
27
27
 
@@ -30,10 +30,10 @@ void msgpack_rmem_destroy(msgpack_rmem_t* pm)
30
30
  msgpack_rmem_chunk_t* c = pm->array_first;
31
31
  msgpack_rmem_chunk_t* cend = pm->array_last;
32
32
  for(; c != cend; c++) {
33
- free(c->pages);
33
+ xfree(c->pages);
34
34
  }
35
- free(pm->head.pages);
36
- free(pm->array_first);
35
+ xfree(pm->head.pages);
36
+ xfree(pm->array_first);
37
37
  }
38
38
 
39
39
  void* _msgpack_rmem_alloc2(msgpack_rmem_t* pm)
@@ -56,7 +56,7 @@ void* _msgpack_rmem_alloc2(msgpack_rmem_t* pm)
56
56
  size_t capacity = c - pm->array_first;
57
57
  size_t length = last - pm->array_first;
58
58
  capacity = (capacity == 0) ? 8 : capacity * 2;
59
- msgpack_rmem_chunk_t* array = realloc(pm->array_first, capacity * sizeof(msgpack_rmem_chunk_t));
59
+ msgpack_rmem_chunk_t* array = xrealloc(pm->array_first, capacity * sizeof(msgpack_rmem_chunk_t));
60
60
  pm->array_first = array;
61
61
  pm->array_last = array + length;
62
62
  pm->array_end = array + capacity;
@@ -71,7 +71,7 @@ void* _msgpack_rmem_alloc2(msgpack_rmem_t* pm)
71
71
  *c = tmp;
72
72
 
73
73
  pm->head.mask = 0xffffffff & (~1); /* "& (~1)" means first chunk is already allocated */
74
- pm->head.pages = malloc(MSGPACK_RMEM_PAGE_SIZE * 32);
74
+ pm->head.pages = xmalloc(MSGPACK_RMEM_PAGE_SIZE * 32);
75
75
 
76
76
  return pm->head.pages;
77
77
  }
@@ -81,7 +81,7 @@ void _msgpack_rmem_chunk_free(msgpack_rmem_t* pm, msgpack_rmem_chunk_t* c)
81
81
  if(pm->array_first->mask == 0xffffffff) {
82
82
  /* free and move to last */
83
83
  pm->array_last--;
84
- free(c->pages);
84
+ xfree(c->pages);
85
85
  *c = *pm->array_last;
86
86
  return;
87
87
  }
@@ -68,7 +68,7 @@ void _msgpack_unpacker_init(msgpack_unpacker_t* uk)
68
68
  /*memset(uk->stack, 0, MSGPACK_UNPACKER_STACK_CAPACITY);*/
69
69
  #else
70
70
  /*uk->stack = calloc(MSGPACK_UNPACKER_STACK_CAPACITY, sizeof(msgpack_unpacker_stack_t));*/
71
- uk->stack = malloc(MSGPACK_UNPACKER_STACK_CAPACITY * sizeof(msgpack_unpacker_stack_t));
71
+ uk->stack = xmalloc(MSGPACK_UNPACKER_STACK_CAPACITY * sizeof(msgpack_unpacker_stack_t));
72
72
  #endif
73
73
  uk->stack_capacity = MSGPACK_UNPACKER_STACK_CAPACITY;
74
74
  }
@@ -78,7 +78,7 @@ void _msgpack_unpacker_destroy(msgpack_unpacker_t* uk)
78
78
  #ifdef UNPACKER_STACK_RMEM
79
79
  msgpack_rmem_free(&s_stack_rmem, uk->stack);
80
80
  #else
81
- free(uk->stack);
81
+ xfree(uk->stack);
82
82
  #endif
83
83
 
84
84
  msgpack_buffer_destroy(UNPACKER_BUFFER_(uk));
@@ -380,7 +380,7 @@ static int read_primitive(msgpack_unpacker_t* uk)
380
380
  case 0xc8: // ext 16
381
381
  {
382
382
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 3);
383
- uint16_t length = cb->u16;
383
+ uint16_t length = _msgpack_be16(cb->u16);
384
384
  int ext_type = cb->buffer[2];
385
385
  if(length == 0) {
386
386
  return object_complete_ext(uk, ext_type, rb_str_buf_new(0));
@@ -392,7 +392,7 @@ static int read_primitive(msgpack_unpacker_t* uk)
392
392
  case 0xc9: // ext 32
393
393
  {
394
394
  READ_CAST_BLOCK_OR_RETURN_EOF(cb, uk, 5);
395
- uint32_t length = cb->u32;
395
+ uint32_t length = _msgpack_be32(cb->u32);
396
396
  int ext_type = cb->buffer[4];
397
397
  if(length == 0) {
398
398
  return object_complete_ext(uk, ext_type, rb_str_buf_new(0));
@@ -47,7 +47,7 @@ static void Unpacker_free(msgpack_unpacker_t* uk)
47
47
  }
48
48
  msgpack_unpacker_ext_registry_destroy(&uk->ext_registry);
49
49
  _msgpack_unpacker_destroy(uk);
50
- free(uk);
50
+ xfree(uk);
51
51
  }
52
52
 
53
53
  static void Unpacker_mark(msgpack_unpacker_t* uk)
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module MessagePack
2
- VERSION = "0.7.0"
2
+ VERSION = "0.7.1"
3
3
  end
data/spec/packer_spec.rb CHANGED
@@ -223,4 +223,34 @@ describe MessagePack::Packer do
223
223
  expect(two[:packer]).to eq(:to_msgpack_ext)
224
224
  end
225
225
  end
226
+
227
+ describe "ext formats" do
228
+ [1, 2, 4, 8, 16].zip([0xd4, 0xd5, 0xd6, 0xd7, 0xd8]).each do |n,b|
229
+ it "msgpack fixext #{n} format" do
230
+ MessagePack::ExtensionValue.new(1, "a"*n).to_msgpack.should ==
231
+ [b, 1].pack('CC') + "a"*n
232
+ end
233
+ end
234
+
235
+ it "msgpack ext 8 format" do
236
+ MessagePack::ExtensionValue.new(1, "").to_msgpack.should ==
237
+ [0xc7, 0, 1].pack('CCC') + ""
238
+ MessagePack::ExtensionValue.new(-1, "a"*255).to_msgpack.should ==
239
+ [0xc7, 255, -1].pack('CCC') + "a"*255
240
+ end
241
+
242
+ it "msgpack ext 16 format" do
243
+ MessagePack::ExtensionValue.new(1, "a"*256).to_msgpack.should ==
244
+ [0xc8, 256, 1].pack('CnC') + "a"*256
245
+ MessagePack::ExtensionValue.new(-1, "a"*65535).to_msgpack.should ==
246
+ [0xc8, 65535, -1].pack('CnC') + "a"*65535
247
+ end
248
+
249
+ it "msgpack ext 32 format" do
250
+ MessagePack::ExtensionValue.new(1, "a"*65536).to_msgpack.should ==
251
+ [0xc9, 65536, 1].pack('CNC') + "a"*65536
252
+ MessagePack::ExtensionValue.new(-1, "a"*65538).to_msgpack.should ==
253
+ [0xc9, 65538, -1].pack('CNC') + "a"*65538
254
+ end
255
+ end
226
256
  end
@@ -260,6 +260,33 @@ describe MessagePack::Unpacker do
260
260
  MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
261
261
  end
262
262
 
263
+ describe "ext formats" do
264
+ let(:unpacker) { MessagePack::Unpacker.new(allow_unknown_ext: true) }
265
+
266
+ [1, 2, 4, 8, 16].zip([0xd4, 0xd5, 0xd6, 0xd7, 0xd8]).each do |n,b|
267
+ it "msgpack fixext #{n} format" do
268
+ unpacker.feed([b, 1].pack('CC') + "a"*n).unpack.should == MessagePack::ExtensionValue.new(1, "a"*n)
269
+ unpacker.feed([b, -1].pack('CC') + "a"*n).unpack.should == MessagePack::ExtensionValue.new(-1, "a"*n)
270
+ end
271
+ end
272
+
273
+ it "msgpack ext 8 format" do
274
+ unpacker.feed([0xc7, 0, 1].pack('CCC')).unpack.should == MessagePack::ExtensionValue.new(1, "")
275
+ unpacker.feed([0xc7, 255, -1].pack('CCC') + "a"*255).unpack.should == MessagePack::ExtensionValue.new(-1, "a"*255)
276
+ end
277
+
278
+ it "msgpack ext 16 format" do
279
+ unpacker.feed([0xc8, 0, 1].pack('CnC')).unpack.should == MessagePack::ExtensionValue.new(1, "")
280
+ unpacker.feed([0xc8, 256, -1].pack('CnC') + "a"*256).unpack.should == MessagePack::ExtensionValue.new(-1, "a"*256)
281
+ end
282
+
283
+ it "msgpack ext 32 format" do
284
+ unpacker.feed([0xc9, 0, 1].pack('CNC')).unpack.should == MessagePack::ExtensionValue.new(1, "")
285
+ unpacker.feed([0xc9, 256, -1].pack('CNC') + "a"*256).unpack.should == MessagePack::ExtensionValue.new(-1, "a"*256)
286
+ unpacker.feed([0xc9, 65536, -1].pack('CNC') + "a"*65536).unpack.should == MessagePack::ExtensionValue.new(-1, "a"*65536)
287
+ end
288
+ end
289
+
263
290
  class ValueOne
264
291
  attr_reader :num
265
292
  def initialize(num)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Sadayuki Furuhashi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-24 00:00:00.000000000 Z
13
+ date: 2015-11-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler