From: Giovanni Bechis Date: Thu, 4 Jun 2020 07:04:09 +0000 (+0000) Subject: Add error checks in md_json_readb X-Git-Tag: 2.5.0-alpha2-ci-test-only~1403 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b7ba286b6e856ae3affd4563c7ff84493bbaa66a;p=thirdparty%2Fapache%2Fhttpd.git Add error checks in md_json_readb git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1878462 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/md/md_json.c b/modules/md/md_json.c index 73120d78ed2..5785523ba4e 100644 --- a/modules/md/md_json.c +++ b/modules/md/md_json.c @@ -1101,11 +1101,14 @@ apr_status_t md_json_readb(md_json_t **pjson, apr_pool_t *pool, apr_bucket_briga json_t *j; j = json_load_callback(load_cb, bb, 0, &error); - if (!j) { - return APR_EINVAL; + if (j) { + *pjson = json_create(pool, j); + } else { + md_log_perror(MD_LOG_MARK, MD_LOG_ERR, 0, pool, + "failed to load JSON file: %s (line %d:%d)", + error.text, error.line, error.column); } - *pjson = json_create(pool, j); - return APR_SUCCESS; + return (j && *pjson) ? APR_SUCCESS : APR_EINVAL; } static size_t load_file_cb(void *data, size_t max_len, void *baton)