summaryrefslogtreecommitdiff
path: root/ext/json/JSON_parser.c
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
committerSean Finney <seanius@debian.org>2009-06-24 22:49:04 +0200
commit84f4ca9b07fe5b73d840258f4aa7c1eb534c4253 (patch)
tree9829bd578af8a4a8b42b04277f9067e00dc5ad90 /ext/json/JSON_parser.c
parent6821b67124604da690c5e9276d5370d679c63ac8 (diff)
downloadphp-84f4ca9b07fe5b73d840258f4aa7c1eb534c4253.tar.gz
Imported Upstream version 5.3.0~RC4upstream/5.3.0_RC4upstream/5.3.0.RC4
Diffstat (limited to 'ext/json/JSON_parser.c')
-rw-r--r--ext/json/JSON_parser.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/json/JSON_parser.c b/ext/json/JSON_parser.c
index 6aae849f1..259b77b08 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;
}
@@ -352,7 +360,7 @@ static void utf16_to_utf8(smart_str *buf, unsigned short utf16)
| (utf16 & 0x3ff)) + 0x10000;
buf->len -= 3;
- smart_str_appendc(buf, 0xf0 | (utf32 >> 18));
+ smart_str_appendc(buf, (unsigned char) (0xf0 | (utf32 >> 18)));
smart_str_appendc(buf, 0x80 | ((utf32 >> 12) & 0x3f));
smart_str_appendc(buf, 0x80 | ((utf32 >> 6) & 0x3f));
smart_str_appendc(buf, 0x80 | (utf32 & 0x3f));