1
0
mirror of https://github.com/php/php-src.git synced 2026-04-29 11:13:36 +02:00

Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()).

This commit is contained in:
Ilia Alshanetsky
2011-06-01 09:44:38 +00:00
parent cb7f656de7
commit f4f2aa7583
3 changed files with 56 additions and 0 deletions
+4
View File
@@ -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)
+2
View File
@@ -589,6 +589,8 @@ static PHP_FUNCTION(json_decode)
return;
}
JSON_G(error_code) = 0;
if (!str_len) {
RETURN_NULL();
}
+50
View File
@@ -0,0 +1,50 @@
--TEST--
Bug #54484 (Empty string in json_decode doesn't reset json_last_error)
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
json_decode('{"test":"test"}');
var_dump(json_last_error());
json_decode("");
var_dump(json_last_error());
json_decode("invalid json");
var_dump(json_last_error());
json_decode("");
var_dump(json_last_error());
?>
--EXPECT--
int(0)
int(0)
int(4)
int(0)
--TEST--
Bug #54484 (Empty string in json_decode doesn't reset json_last_error)
--SKIPIF--
<?php if (!extension_loaded("json")) print "skip"; ?>
--FILE--
<?php
json_decode('{"test":"test"}');
var_dump(json_last_error());
json_decode("");
var_dump(json_last_error());
json_decode("invalid json");
var_dump(json_last_error());
json_decode("");
var_dump(json_last_error());
?>
--EXPECT--
int(0)
int(0)
int(4)
int(0)