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

index b3049d002db8687e03c34e62620b68a3ce62fcc4..e07a1a4ff56ee59983f1deafbab4d7389e520d96 100644 (file)
@@ -531,6 +531,8 @@ static PHP_FUNCTION(json_decode)
                RETVAL_NULL();
                if (str_len == 4) {
                        if (!strcasecmp(str, "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, "true")) {
                                RETVAL_BOOL(1);
@@ -547,6 +549,10 @@ static PHP_FUNCTION(json_decode)
                        }
                }
 
+               if (Z_TYPE_P(return_value) != IS_NULL) {
+                       jp->error_code = PHP_JSON_ERROR_NONE;
+               }
+
                zval_dtor(z);
        }
        FREE_ZVAL(z);