syck 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/syck/rubyext.c +21 -9
- data/test/test_large_input.rb +26 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e27c3b9b21ba6e707479bdbfeadbd583d68cfef4b6f2e4882faff6316fc09f19
|
|
4
|
+
data.tar.gz: d5bfc236838cee8709f19789e641eadf9c218e39b668db1462a5a704cea444b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f5de63e2fcd1c793fc25049c3cc36d7fcbb30c661f74b41af5e2f13cdca7145d99820812c6a3729a627810286c2a70b318e3ff2f252f9620514dad9f099ae0f
|
|
7
|
+
data.tar.gz: a98dbb0151212292f8d2cc47ef00730b607fb0032427c0eec333a66a4b52872429f8c85e9e9aa3effc1ae716cf24e92be7920f9ee68bf556021cc3d2955dfdf6
|
data/ext/syck/rubyext.c
CHANGED
|
@@ -148,6 +148,7 @@ rb_syck_compile(VALUE self, VALUE port)
|
|
|
148
148
|
SYMID oid;
|
|
149
149
|
int taint;
|
|
150
150
|
char *ret;
|
|
151
|
+
long blen;
|
|
151
152
|
VALUE bc;
|
|
152
153
|
bytestring_t *sav = NULL;
|
|
153
154
|
void *data = NULL;
|
|
@@ -160,18 +161,25 @@ rb_syck_compile(VALUE self, VALUE port)
|
|
|
160
161
|
syck_parser_taguri_expansion( parser, 0 );
|
|
161
162
|
oid = syck_parse( parser );
|
|
162
163
|
if (!syck_lookup_sym( parser, oid, &data )) {
|
|
164
|
+
syck_free_parser( parser );
|
|
163
165
|
rb_raise(rb_eSyntaxError, "root node <%p> not found", (void *)oid);
|
|
164
166
|
}
|
|
165
167
|
sav = data;
|
|
166
168
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
/*
|
|
170
|
+
* Steal the buffer from the parser's symbol table (S_FREE ignores
|
|
171
|
+
* the NULLed pointer) so the parser can be freed before rb_str_new,
|
|
172
|
+
* which may raise and would otherwise leak the parser.
|
|
173
|
+
*/
|
|
174
|
+
ret = sav->buffer;
|
|
175
|
+
sav->buffer = NULL;
|
|
172
176
|
syck_free_parser( parser );
|
|
173
177
|
|
|
174
|
-
|
|
178
|
+
blen = (long)strlen( ret );
|
|
179
|
+
bc = rb_str_new( 0, blen + 2 );
|
|
180
|
+
memcpy( RSTRING_PTR(bc), "D\n", 2 );
|
|
181
|
+
memcpy( RSTRING_PTR(bc) + 2, ret, (size_t)blen );
|
|
182
|
+
S_FREE( ret );
|
|
175
183
|
if ( taint ) OBJ_TAINT( bc );
|
|
176
184
|
return bc;
|
|
177
185
|
}
|
|
@@ -1213,13 +1221,17 @@ syck_set_ivars(
|
|
|
1213
1221
|
)
|
|
1214
1222
|
{
|
|
1215
1223
|
VALUE ivname = rb_ary_entry( vars, 0 );
|
|
1224
|
+
VALUE ivn_v;
|
|
1216
1225
|
char *ivn;
|
|
1226
|
+
long ivn_len;
|
|
1217
1227
|
StringValue( ivname );
|
|
1218
|
-
|
|
1228
|
+
ivn_len = RSTRING_LEN(ivname);
|
|
1229
|
+
ivn = ALLOCV_N( char, ivn_v, ivn_len + 2 );
|
|
1219
1230
|
ivn[0] = '@';
|
|
1220
|
-
ivn
|
|
1221
|
-
|
|
1231
|
+
memcpy( ivn + 1, RSTRING_PTR(ivname), (size_t)ivn_len );
|
|
1232
|
+
ivn[ivn_len + 1] = '\0';
|
|
1222
1233
|
rb_iv_set( obj, ivn, rb_ary_entry( vars, 1 ) );
|
|
1234
|
+
ALLOCV_END( ivn_v );
|
|
1223
1235
|
return Qnil;
|
|
1224
1236
|
}
|
|
1225
1237
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
|
|
3
|
+
module Syck
|
|
4
|
+
# Both of these sized an `alloca` from the document. They are run on a Thread
|
|
5
|
+
# because a Ruby thread's stack is far smaller than the main stack, which is
|
|
6
|
+
# the shape a web or job worker actually has.
|
|
7
|
+
class TestLargeInput < Test::Unit::TestCase
|
|
8
|
+
SIZE = 4 * 1024 * 1024
|
|
9
|
+
|
|
10
|
+
def on_thread
|
|
11
|
+
Thread.new { yield }.value
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def test_long_ivar_name
|
|
15
|
+
doc = "--- !ruby/object:Object\n" + ('n' * SIZE) + ": 1\n"
|
|
16
|
+
obj = on_thread { Syck.load(doc) }
|
|
17
|
+
assert_equal 1, obj.instance_variable_get("@#{'n' * SIZE}")
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_long_compile_input
|
|
21
|
+
doc = "--- \n" + (0...(SIZE / 20)).map { |i| "k#{i}: v#{i}\n" }.join
|
|
22
|
+
bc = on_thread { Syck.compile(doc) }
|
|
23
|
+
assert_equal "D\n", bc[0, 2]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: syck
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.6.
|
|
4
|
+
version: 1.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hiroshi SHIBATA
|
|
@@ -107,6 +107,7 @@ files:
|
|
|
107
107
|
- test/test_exception.rb
|
|
108
108
|
- test/test_gc.rb
|
|
109
109
|
- test/test_hash.rb
|
|
110
|
+
- test/test_large_input.rb
|
|
110
111
|
- test/test_null.rb
|
|
111
112
|
- test/test_omap.rb
|
|
112
113
|
- test/test_set.rb
|
|
@@ -147,6 +148,7 @@ test_files:
|
|
|
147
148
|
- test/test_exception.rb
|
|
148
149
|
- test/test_gc.rb
|
|
149
150
|
- test/test_hash.rb
|
|
151
|
+
- test/test_large_input.rb
|
|
150
152
|
- test/test_null.rb
|
|
151
153
|
- test/test_omap.rb
|
|
152
154
|
- test/test_set.rb
|