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.3.7RC1~57 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f4f2aa7583e19a63bf9c845b0bcb707bccb5cb19;p=php Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()). --- diff --git a/NEWS b/NEWS index f7f9d4b3b5..29d6bd95bc 100644 --- a/NEWS +++ b/NEWS @@ -91,6 +91,10 @@ PHP NEWS . Implemented FR #54540 (Allow loading of arbitrary resource bundles when fallback is disabled). (David Zuelke, Stas) +- json extension: + . Fixed bug #54484 (Empty string in json_decode doesn't reset + json_last_error()). (Ilia) + - LDAP extension: . Fixed bug #53339 (Fails to build when compilng with gcc 4.5 and DSO libraries). (Clint Byrum, Raphael) diff --git a/ext/json/json.c b/ext/json/json.c index ec76c1d5f3..5d3e441980 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -589,6 +589,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..a8f310885b --- /dev/null +++ b/ext/json/tests/bug54484.phpt @@ -0,0 +1,50 @@ +--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) +--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)