From: Ilia Alshanetsky Date: Wed, 1 Jun 2011 09:44:38 +0000 (+0000) Subject: Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()). X-Git-Tag: php-5.5.0alpha1~2022 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=850db4b315eb56d261098a6f42df6a8375cbd937;p=php Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()). --- diff --git a/ext/json/json.c b/ext/json/json.c index db3fad9871..7231e647c3 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -703,6 +703,8 @@ static PHP_FUNCTION(json_decode) return; } + JSON_G(error_code) = 0; + if (!str_len) { RETURN_NULL(); } diff --git a/ext/json/tests/bug54484.phpt b/ext/json/tests/bug54484.phpt new file mode 100644 index 0000000000..d698ab5416 --- /dev/null +++ b/ext/json/tests/bug54484.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #54484 (Empty string in json_decode doesn't reset json_last_error) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(0) +int(0) +int(4) +int(0)