Allow the json_decode() depth to be any size, but keep the static one around for now. It might make sense to allow an unbound depth.

This commit is contained in:
Scott MacVicar 2009-05-14 00:13:57 +00:00
parent 5af0cbef65
commit 1c1ba8cc06
3 changed files with 14 additions and 7 deletions

View file

@ -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;
}