diff options
author | Scott MacVicar <scottmac@php.net> | 2008-12-24 18:09:00 +0000 |
---|---|---|
committer | Scott MacVicar <scottmac@php.net> | 2008-12-24 18:09:00 +0000 |
commit | 0d860e26caba0c4ff0e3b145d44bac164d5428a6 (patch) | |
tree | bbfac4606d631b7795804fbf211dd6321cb6044e | |
parent | b80786d06653522a3ea91e5f3c077c8cede14608 (diff) | |
download | php-git-0d860e26caba0c4ff0e3b145d44bac164d5428a6.tar.gz |
Make sure we clear out the error when the scalar version decoding works.
-rw-r--r-- | ext/json/json.c | 12 |
1 files changed, 12 insertions, 0 deletions
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); |