summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Frank <flori@ping.de>2016-06-11 18:59:42 +0200
committerGitHub <noreply@github.com>2016-06-11 18:59:42 +0200
commitca0ffe9718d61d59090cfc0d567400e264bf6866 (patch)
tree42818796633f1b1a9562f629fb3969eee0a8d521
parent6327cbb815226cbdfe24b7ed41e015c6c1f2ac20 (diff)
parent4aae95f41b6b972245d15e52c46dbd5f278ff2c2 (diff)
downloadjson-ca0ffe9718d61d59090cfc0d567400e264bf6866.tar.gz
Merge pull request #260 from tenderlove/memuse
resize strings after parsing
-rw-r--r--ext/json/ext/parser/parser.c2
-rw-r--r--ext/json/ext/parser/parser.rl2
2 files changed, 4 insertions, 0 deletions
diff --git a/ext/json/ext/parser/parser.c b/ext/json/ext/parser/parser.c
index 5b2e61c..ea95e71 100644
--- a/ext/json/ext/parser/parser.c
+++ b/ext/json/ext/parser/parser.c
@@ -1632,6 +1632,8 @@ case 7:
if (json->symbolize_names && json->parsing_name) {
*result = rb_str_intern(*result);
+ } else {
+ rb_str_resize(*result, RSTRING_LEN(*result));
}
if (cs >= JSON_string_first_final) {
return p + 1;
diff --git a/ext/json/ext/parser/parser.rl b/ext/json/ext/parser/parser.rl
index f3933cb..157b001 100644
--- a/ext/json/ext/parser/parser.rl
+++ b/ext/json/ext/parser/parser.rl
@@ -527,6 +527,8 @@ static char *JSON_parse_string(JSON_Parser *json, char *p, char *pe, VALUE *resu
if (json->symbolize_names && json->parsing_name) {
*result = rb_str_intern(*result);
+ } else {
+ rb_str_resize(*result, RSTRING_LEN(*result));
}
if (cs >= JSON_string_first_final) {
return p + 1;