From: Scott MacVicar Date: Wed, 24 Dec 2008 18:09:09 +0000 (+0000) Subject: MFH Make sure we clear out the error when the scalar version decoding works. X-Git-Tag: php-5.3.0beta1~386 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7fe245af8513f0a3d6410480022c7d10e01a99b5;p=php MFH Make sure we clear out the error when the scalar version decoding works. --- diff --git a/ext/json/json.c b/ext/json/json.c index b3049d002d..e07a1a4ff5 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -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);