File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ PHP NEWS
2424 . Fixed bug #68571 (core dump when webserver close the socket).
2525 (redfoxli069 at gmail dot com, Laruence)
2626
27+ - JSON:
28+ . Fixed bug #68938 (json_decode() decodes empty string without error).
29+ (jeremy at bat-country dot us)
30+
2731- Libxml:
2832 . Fixed bug #64938 (libxml_disable_entity_loader setting is shared
2933 between threads). (Martin Jansen)
Original file line number Diff line number Diff line change @@ -818,6 +818,7 @@ static PHP_FUNCTION(json_decode)
818818 JSON_G (error_code ) = 0 ;
819819
820820 if (!str_len ) {
821+ JSON_G (error_code ) = PHP_JSON_ERROR_SYNTAX ;
821822 RETURN_NULL ();
822823 }
823824
Original file line number Diff line number Diff line change @@ -15,11 +15,16 @@ json_decode("invalid json");
1515var_dump (json_last_error ());
1616
1717
18+ json_decode ("\001 invalid json " );
19+ var_dump (json_last_error ());
20+
21+
1822json_decode ("" );
1923var_dump (json_last_error ());
2024?>
2125--EXPECT--
2226int(0)
23- int(0)
2427int(4)
25- int(0)
28+ int(4)
29+ int(3)
30+ int(4)
Original file line number Diff line number Diff line change 1+ --TEST--
2+ Bug #68938 (json_decode() decodes empty string without indicating error)
3+ --SKIPIF--
4+ <?php if (!extension_loaded ("json " )) print "skip " ; ?>
5+ --FILE--
6+ <?php
7+ json_decode ("" );
8+ var_dump (json_last_error ());
9+ ?>
10+ --EXPECT--
11+ int(4)
You can’t perform that action at this time.
0 commit comments