summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott MacVicar <scottmac@php.net>2008-12-24 18:09:00 +0000
committerScott MacVicar <scottmac@php.net>2008-12-24 18:09:00 +0000
commit0d860e26caba0c4ff0e3b145d44bac164d5428a6 (patch)
treebbfac4606d631b7795804fbf211dd6321cb6044e
parentb80786d06653522a3ea91e5f3c077c8cede14608 (diff)
downloadphp-git-0d860e26caba0c4ff0e3b145d44bac164d5428a6.tar.gz
Make sure we clear out the error when the scalar version decoding works.
-rw-r--r--ext/json/json.c12
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);