oj 3.14.0 → 3.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/ext/oj/object.c +6 -6
- data/ext/oj/parse.c +1 -2
- data/ext/oj/saj2.c +4 -0
- data/lib/oj/version.rb +1 -1
- data/test/foo.rb +3 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85912fe57610093a2cd9a8aeed44ac537bfe329c17988ea56624ec55f11fb9f5
|
4
|
+
data.tar.gz: f44e342c4381b4487e32ef82ec686ac47115061480c74c835d93bdb12e4c8b7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2cfa1959b394dd3a3313fd23756b98efb8a32232d4204892e9c29843e61f05d3cd9288337609fc6e67275a2c383cd2f835e028d66084e873b737f0cd4bb9211
|
7
|
+
data.tar.gz: 9364d9503225952d51a9e9fb8ff8b6a6fb74424b7a2adad2d5d1b0f11ebf06c02230553ff8f8c3f0f991fe315e1a6c1904e9e420b56a2832b0c5e48cfe3dd6e3
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
-
## 3.14.
|
3
|
+
## 3.14.1 - 2023-02-01
|
4
|
+
|
5
|
+
- Fixed issue with uninitialized handler for Oj::Parser::Saj.
|
6
|
+
|
7
|
+
- Fixed hang on unterminated string with a \0 byte in parse.c.
|
8
|
+
|
9
|
+
## 3.14.0 - 2023-01-30
|
4
10
|
|
5
11
|
- Tracing is now a compile time option giving a 15 to 20% performance boost.
|
6
12
|
|
data/ext/oj/object.c
CHANGED
@@ -308,7 +308,7 @@ static int hat_value(ParseInfo pi, Val parent, const char *key, size_t klen, vol
|
|
308
308
|
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "Invalid struct data");
|
309
309
|
return 1;
|
310
310
|
}
|
311
|
-
e1 = *
|
311
|
+
e1 = *RARRAY_CONST_PTR(value);
|
312
312
|
// check for anonymous Struct
|
313
313
|
if (T_ARRAY == rb_type(e1)) {
|
314
314
|
VALUE args[1024];
|
@@ -322,10 +322,10 @@ static int hat_value(ParseInfo pi, Val parent, const char *key, size_t klen, vol
|
|
322
322
|
sc = rb_funcall2(rb_cStruct, oj_new_id, cnt, args);
|
323
323
|
} else {
|
324
324
|
// If struct is not defined then we let this fail and raise an exception.
|
325
|
-
sc = oj_name2struct(pi, *
|
325
|
+
sc = oj_name2struct(pi, *RARRAY_CONST_PTR(value), rb_eArgError);
|
326
326
|
}
|
327
327
|
if (sc == rb_cRange) {
|
328
|
-
parent->val = rb_class_new_instance(len - 1,
|
328
|
+
parent->val = rb_class_new_instance(len - 1, RARRAY_CONST_PTR(value) + 1, rb_cRange);
|
329
329
|
} else {
|
330
330
|
// Create a properly initialized struct instance without calling the initialize method.
|
331
331
|
parent->val = rb_obj_alloc(sc);
|
@@ -346,7 +346,7 @@ static int hat_value(ParseInfo pi, Val parent, const char *key, size_t klen, vol
|
|
346
346
|
int i;
|
347
347
|
|
348
348
|
for (i = 0; i < len - 1; i++) {
|
349
|
-
rb_struct_aset(parent->val, INT2FIX(i),
|
349
|
+
rb_struct_aset(parent->val, INT2FIX(i), RARRAY_CONST_PTR(value)[i + 1]);
|
350
350
|
}
|
351
351
|
}
|
352
352
|
}
|
@@ -359,7 +359,7 @@ static int hat_value(ParseInfo pi, Val parent, const char *key, size_t klen, vol
|
|
359
359
|
return 1;
|
360
360
|
}
|
361
361
|
parent->val = rb_hash_new();
|
362
|
-
a =
|
362
|
+
a = RARRAY_CONST_PTR(value);
|
363
363
|
rb_hash_aset(parent->val, *a, a[1]);
|
364
364
|
|
365
365
|
return 1;
|
@@ -546,7 +546,7 @@ WHICH_TYPE:
|
|
546
546
|
} else {
|
547
547
|
if (3 <= klen && '^' == *key && '#' == key[1] && T_ARRAY == rb_type(value)) {
|
548
548
|
long len = RARRAY_LEN(value);
|
549
|
-
volatile VALUE *a =
|
549
|
+
volatile VALUE *a = RARRAY_CONST_PTR(value);
|
550
550
|
|
551
551
|
if (2 != len) {
|
552
552
|
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "invalid hash pair");
|
data/ext/oj/parse.c
CHANGED
@@ -236,7 +236,7 @@ static void read_escaped_str(ParseInfo pi, const char *start) {
|
|
236
236
|
|
237
237
|
for (s = pi->cur; '"' != *s;) {
|
238
238
|
const char *scanned = scan_func(s, pi->end);
|
239
|
-
if (scanned >= pi->end) {
|
239
|
+
if (scanned >= pi->end || '\0' == *s) {
|
240
240
|
oj_set_error_at(pi,
|
241
241
|
oj_parse_error_class,
|
242
242
|
__FILE__,
|
@@ -245,7 +245,6 @@ static void read_escaped_str(ParseInfo pi, const char *start) {
|
|
245
245
|
buf_cleanup(&buf);
|
246
246
|
return;
|
247
247
|
}
|
248
|
-
|
249
248
|
buf_append_string(&buf, s, (size_t)(scanned - s));
|
250
249
|
s = scanned;
|
251
250
|
|
data/ext/oj/saj2.c
CHANGED
@@ -578,7 +578,11 @@ void oj_init_saj(ojParser p, Saj d) {
|
|
578
578
|
d->klen = 256;
|
579
579
|
d->keys = ALLOC_N(VALUE, d->klen);
|
580
580
|
d->tail = d->keys;
|
581
|
+
d->handler = Qnil;
|
581
582
|
d->str_cache = cache_create(0, form_str, true, false);
|
583
|
+
d->cache_str = 16;
|
584
|
+
d->cache_keys = true;
|
585
|
+
d->thread_safe = false;
|
582
586
|
|
583
587
|
p->ctx = (void *)d;
|
584
588
|
reset(p);
|
data/lib/oj/version.rb
CHANGED
data/test/foo.rb
CHANGED
@@ -7,23 +7,7 @@ $: << File.join(File.dirname(__FILE__), "../ext")
|
|
7
7
|
require "oj"
|
8
8
|
|
9
9
|
|
10
|
-
|
10
|
+
s = "{\"f1\":\"data\\nW\x0\"}\r\n"
|
11
|
+
#s = "{\"f1\":\"data\\nW\"}\r\n"
|
11
12
|
|
12
|
-
|
13
|
-
"array": [
|
14
|
-
{
|
15
|
-
"num" : 3,
|
16
|
-
"string": "message",
|
17
|
-
"hash" : {
|
18
|
-
"h2" : {
|
19
|
-
"a" : [ 1, 2, 3 ]
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
23
|
-
],
|
24
|
-
"boolean" : true
|
25
|
-
}|
|
26
|
-
|
27
|
-
1_000_000.times do
|
28
|
-
e = Oj.load(json)
|
29
|
-
end
|
13
|
+
j = Oj.load(s)
|
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: 3.14.
|
4
|
+
version: 3.14.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|