From 898721f7f1b599dff06d3c494c700304dcbce121 Mon Sep 17 00:00:00 2001 From: Graham Leggett Date: Sun, 8 Jul 2018 16:40:43 +0000 Subject: 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 --- json/apr_json_decode.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'json') 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 { */ -- cgit v1.2.1