oj 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of oj might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/ext/oj/dump.c +13 -10
- data/lib/oj/version.rb +1 -1
- data/test/bug.rb +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f86c65032eab3ae341bf09bede8c0fa8494a5443
|
4
|
+
data.tar.gz: c62cd79d31ffa2035698a47ed2096e17513beb4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c416b20f1d0972be265256950dcbf529802f92eda83b0f321f20a316a377a17cd3144267a70199f0640f975960bd8182e0bd31683baed77dcb1575fef67a88f8
|
7
|
+
data.tar.gz: 7c52c57286ed461fba95108bba72a31eec77ca6340e4f6fe4e622abe31fdfad68dbd0b3f1c05558f225547762e8d024143477935618d6a4d7e21db3f3de03729
|
data/README.md
CHANGED
@@ -21,9 +21,9 @@ Follow [@peterohler on Twitter](http://twitter.com/#!/peterohler) for announceme
|
|
21
21
|
[![Build Status](https://secure.travis-ci.org/ohler55/oj.png?branch=master)](http://travis-ci.org/ohler55/oj)
|
22
22
|
|
23
23
|
|
24
|
-
### Current Release 2.4.
|
24
|
+
### Current Release 2.4.2
|
25
25
|
|
26
|
-
-
|
26
|
+
- Thanks to Patrik Rak for a fix to a buffer short copy when dumping with 0 indent.
|
27
27
|
|
28
28
|
[Older release notes](http://www.ohler.com/dev/oj_misc/release_notes.html).
|
29
29
|
|
data/ext/oj/dump.c
CHANGED
@@ -51,6 +51,9 @@
|
|
51
51
|
// Workaround in case INFINITY is not defined in math.h or if the OS is CentOS
|
52
52
|
#define OJ_INFINITY (1.0/0.0)
|
53
53
|
|
54
|
+
// Extra padding at end of buffer.
|
55
|
+
#define BUFFER_EXTRA 10
|
56
|
+
|
54
57
|
typedef unsigned long ulong;
|
55
58
|
|
56
59
|
static void raise_strict(VALUE obj);
|
@@ -228,11 +231,11 @@ grow(Out out, size_t len) {
|
|
228
231
|
size += len;
|
229
232
|
}
|
230
233
|
if (out->allocated) {
|
231
|
-
buf = REALLOC_N(out->buf, char, (size +
|
234
|
+
buf = REALLOC_N(out->buf, char, (size + BUFFER_EXTRA));
|
232
235
|
} else {
|
233
|
-
buf = ALLOC_N(char, (size +
|
236
|
+
buf = ALLOC_N(char, (size + BUFFER_EXTRA));
|
234
237
|
out->allocated = 1;
|
235
|
-
memcpy(buf, out->buf, out->end - out->buf);
|
238
|
+
memcpy(buf, out->buf, out->end - out->buf + BUFFER_EXTRA);
|
236
239
|
}
|
237
240
|
if (0 == buf) {
|
238
241
|
rb_raise(rb_eNoMemError, "Failed to create string. [%d:%s]\n", ENOSPC, strerror(ENOSPC));
|
@@ -488,8 +491,8 @@ dump_cstr(const char *str, size_t cnt, int is_sym, int escape1, Out out) {
|
|
488
491
|
cmap = hibit_friendly_chars;
|
489
492
|
size = hibit_friendly_size((uint8_t*)str, cnt);
|
490
493
|
}
|
491
|
-
if (out->end - out->cur <= (long)size +
|
492
|
-
grow(out, size +
|
494
|
+
if (out->end - out->cur <= (long)size + BUFFER_EXTRA) { // extra 10 for escaped first char, quotes, and sym
|
495
|
+
grow(out, size + BUFFER_EXTRA);
|
493
496
|
}
|
494
497
|
*out->cur++ = '"';
|
495
498
|
if (escape1) {
|
@@ -1717,7 +1720,7 @@ void
|
|
1717
1720
|
oj_dump_obj_to_json(VALUE obj, Options copts, Out out) {
|
1718
1721
|
if (0 == out->buf) {
|
1719
1722
|
out->buf = ALLOC_N(char, 4096);
|
1720
|
-
out->end = out->buf +
|
1723
|
+
out->end = out->buf + 4095 - BUFFER_EXTRA; // 1 less than end plus extra for possible errors
|
1721
1724
|
out->allocated = 1;
|
1722
1725
|
}
|
1723
1726
|
out->cur = out->buf;
|
@@ -1746,7 +1749,7 @@ oj_write_obj_to_file(VALUE obj, const char *path, Options copts) {
|
|
1746
1749
|
int ok;
|
1747
1750
|
|
1748
1751
|
out.buf = buf;
|
1749
|
-
out.end = buf + sizeof(buf) -
|
1752
|
+
out.end = buf + sizeof(buf) - BUFFER_EXTRA;
|
1750
1753
|
out.allocated = 0;
|
1751
1754
|
oj_dump_obj_to_json(obj, copts, &out);
|
1752
1755
|
size = out.cur - out.buf;
|
@@ -1779,7 +1782,7 @@ oj_write_obj_to_stream(VALUE obj, VALUE stream, Options copts) {
|
|
1779
1782
|
#endif
|
1780
1783
|
|
1781
1784
|
out.buf = buf;
|
1782
|
-
out.end = buf + sizeof(buf) -
|
1785
|
+
out.end = buf + sizeof(buf) - BUFFER_EXTRA;
|
1783
1786
|
out.allocated = 0;
|
1784
1787
|
oj_dump_obj_to_json(obj, copts, &out);
|
1785
1788
|
size = out.cur - out.buf;
|
@@ -1988,7 +1991,7 @@ void
|
|
1988
1991
|
oj_dump_leaf_to_json(Leaf leaf, Options copts, Out out) {
|
1989
1992
|
if (0 == out->buf) {
|
1990
1993
|
out->buf = ALLOC_N(char, 4096);
|
1991
|
-
out->end = out->buf +
|
1994
|
+
out->end = out->buf + 4095 - BUFFER_EXTRA; // 1 less than end plus extra for possible errors
|
1992
1995
|
out->allocated = 1;
|
1993
1996
|
}
|
1994
1997
|
out->cur = out->buf;
|
@@ -2007,7 +2010,7 @@ oj_write_leaf_to_file(Leaf leaf, const char *path, Options copts) {
|
|
2007
2010
|
FILE *f;
|
2008
2011
|
|
2009
2012
|
out.buf = buf;
|
2010
|
-
out.end = buf + sizeof(buf) -
|
2013
|
+
out.end = buf + sizeof(buf) - BUFFER_EXTRA;
|
2011
2014
|
out.allocated = 0;
|
2012
2015
|
oj_dump_leaf_to_json(leaf, copts, &out);
|
2013
2016
|
size = out.cur - out.buf;
|
data/lib/oj/version.rb
CHANGED
data/test/bug.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'The fastest JSON parser and object serializer. '
|
14
14
|
email: peter@ohler.com
|