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:
@@ -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)
|
||||
|
||||
@@ -589,6 +589,8 @@ static PHP_FUNCTION(json_decode)
|
||||
return;
|
||||
}
|
||||
|
||||
JSON_G(error_code) = 0;
|
||||
|
||||
if (!str_len) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user