From 0d860e26caba0c4ff0e3b145d44bac164d5428a6 Mon Sep 17 00:00:00 2001 From: Scott MacVicar Date: Wed, 24 Dec 2008 18:09:00 +0000 Subject: [PATCH] Make sure we clear out the error when the scalar version decoding works. --- ext/json/json.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ext/json/json.c b/ext/json/json.c index e84e5abc56..54f78dac9c 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -551,6 +551,8 @@ static PHP_FUNCTION(json_decode) if (str_len == 4) { if (!strcasecmp(str.s, "null")) { + /* We need to explicitly clear the error because its an actual NULL and not an error */ + jp->error_code = PHP_JSON_ERROR_NONE; RETVAL_NULL(); } else if (!strcasecmp(str.s, "true")) { RETVAL_BOOL(1); @@ -566,6 +568,10 @@ static PHP_FUNCTION(json_decode) RETVAL_DOUBLE(d); } } + + if (Z_TYPE_P(return_value) != IS_NULL) { + jp->error_code = PHP_JSON_ERROR_NONE; + } } else { @@ -578,6 +584,8 @@ static PHP_FUNCTION(json_decode) if (str_len == 4) { if (ZEND_U_CASE_EQUAL(IS_UNICODE, str, str_len, "null", sizeof("null")-1)) { + /* We need to explicitly clear the error because its an actual NULL and not an error */ + jp->error_code = PHP_JSON_ERROR_NONE; RETVAL_NULL(); } else if (ZEND_U_CASE_EQUAL(IS_UNICODE, str, str_len, "true", sizeof("true")-1)) { RETVAL_BOOL(1); @@ -593,6 +601,10 @@ static PHP_FUNCTION(json_decode) RETVAL_DOUBLE(d); } } + + if (Z_TYPE_P(return_value) != IS_NULL) { + jp->error_code = PHP_JSON_ERROR_NONE; + } } FREE_ZVAL(z); -- 2.40.0