summaryrefslogtreecommitdiff
path: root/json
diff options
context:
space:
mode:
authorGraham Leggett <minfrin@apache.org>2018-07-08 16:40:43 +0000
committerGraham Leggett <minfrin@apache.org>2018-07-08 16:40:43 +0000
commit898721f7f1b599dff06d3c494c700304dcbce121 (patch)
treeb3865b2d887c13119d59dec894b0325dd218a65f /json
parentd2e4e91024268494c8346f12a3e5959e44020fe6 (diff)
downloadapr-898721f7f1b599dff06d3c494c700304dcbce121.tar.gz
Create the subpool after the failure cases are all considerd.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1835364 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'json')
-rw-r--r--json/apr_json_decode.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/json/apr_json_decode.c b/json/apr_json_decode.c
index 0c441811c..35476a8ee 100644
--- a/json/apr_json_decode.c
+++ b/json/apr_json_decode.c
@@ -354,18 +354,19 @@ static apr_status_t apr_json_decode_array(apr_json_scanner_t * self,
json_link_t *head = NULL, *tail = NULL;
apr_size_t count = 0;
- if ((status = apr_pool_create(&link_pool, self->pool)))
- return status;
-
if (self->p >= self->e) {
status = APR_EOF;
goto out;
}
- self->level--;
- if (self->level < 0) {
+ if (self->level <= 0) {
return APR_EINVAL;
}
+ self->level--;
+
+ if ((status = apr_pool_create(&link_pool, self->pool))) {
+ return status;
+ }
self->p++; /* toss of the leading [ */
@@ -441,10 +442,10 @@ static apr_status_t apr_json_decode_object(apr_json_scanner_t * self,
return APR_EOF;
}
- self->level--;
- if (self->level < 0) {
+ if (self->level <= 0) {
return APR_EINVAL;
}
+ self->level--;
self->p++; /* toss of the leading { */