summaryrefslogtreecommitdiff
path: root/ext/json/JSON_parser.c
diff options
context:
space:
mode:
authorScott MacVicar <scottmac@php.net>2009-05-14 22:02:08 +0000
committerScott MacVicar <scottmac@php.net>2009-05-14 22:02:08 +0000
commitd2a7785878c37fc7b4eac25b5649cade5b745f01 (patch)
tree69dbd3c1f8ec8cb6f4fbff13301ca30aea0a2f16 /ext/json/JSON_parser.c
parentc0ce0e793289b4657380412c39314546b463956b (diff)
downloadphp-git-d2a7785878c37fc7b4eac25b5649cade5b745f01.tar.gz
MFH Allow a custom recursion depth to be specified for json_decode()
Diffstat (limited to 'ext/json/JSON_parser.c')
-rw-r--r--ext/json/JSON_parser.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c
index 6aae849f16..6fbdb54814 100644
--- a/ext/json/JSON_parser.c
+++ b/ext/json/JSON_parser.c
@@ -247,6 +247,11 @@ new_JSON_parser(int depth)
jp->top = -1;
jp->error_code = PHP_JSON_ERROR_NONE;
jp->stack = (int*)ecalloc(depth, sizeof(int));
+ if (depth > JSON_PARSER_DEFAULT_DEPTH) {
+ jp->the_zstack = (zval **)safe_emalloc(depth, sizeof(zval), 0);
+ } else {
+ jp->the_zstack = &jp->the_static_zstack[0];
+ }
push(jp, MODE_DONE);
return jp;
}
@@ -258,6 +263,9 @@ int
free_JSON_parser(JSON_parser jp)
{
efree((void*)jp->stack);
+ if (jp->the_zstack != &jp->the_static_zstack[0]) {
+ efree(jp->the_zstack);
+ }
efree((void*)jp);
return false;
}