File tree Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Expand file tree Collapse file tree 4 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ PHP NEWS
24
24
. Fixed bug #68571 (core dump when webserver close the socket).
25
25
(redfoxli069 at gmail dot com, Laruence)
26
26
27
+ - JSON:
28
+ . Fixed bug #68938 (json_decode() decodes empty string without error).
29
+ (jeremy at bat-country dot us)
30
+
27
31
- Libxml:
28
32
. Fixed bug #64938 (libxml_disable_entity_loader setting is shared
29
33
between threads). (Martin Jansen)
Original file line number Diff line number Diff line change @@ -818,6 +818,7 @@ static PHP_FUNCTION(json_decode)
818
818
JSON_G (error_code ) = 0 ;
819
819
820
820
if (!str_len ) {
821
+ JSON_G (error_code ) = PHP_JSON_ERROR_SYNTAX ;
821
822
RETURN_NULL ();
822
823
}
823
824
Original file line number Diff line number Diff line change @@ -15,11 +15,16 @@ json_decode("invalid json");
15
15
var_dump (json_last_error ());
16
16
17
17
18
+ json_decode ("\001 invalid json " );
19
+ var_dump (json_last_error ());
20
+
21
+
18
22
json_decode ("" );
19
23
var_dump (json_last_error ());
20
24
?>
21
25
--EXPECT--
22
26
int(0)
23
- int(0)
24
27
int(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