]> granicus.if.org Git - php/commitdiff
Make sure we clear out the error when the scalar version decoding works.
authorScott MacVicar <scottmac@php.net>
Wed, 24 Dec 2008 18:09:00 +0000 (18:09 +0000)
committerScott MacVicar <scottmac@php.net>
Wed, 24 Dec 2008 18:09:00 +0000 (18:09 +0000)
ext/json/json.c

index e84e5abc565f40cfc2db92f371af73a34b8cf290..54f78dac9c35dd1101114be8adeadeba937a0455 100644 (file)
@@ -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);