mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()).
This commit is contained in:
parent
6406521a44
commit
a7dfb31557
@ -703,6 +703,8 @@ static PHP_FUNCTION(json_decode)
|
||||
return;
|
||||
}
|
||||
|
||||
JSON_G(error_code) = 0;
|
||||
|
||||
if (!str_len) {
|
||||
RETURN_NULL();
|
||||
}
|
||||
|
25
ext/json/tests/bug54484.phpt
Normal file
25
ext/json/tests/bug54484.phpt
Normal file
@ -0,0 +1,25 @@
|
||||
--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)
|
Loading…
Reference in New Issue
Block a user