diff --git a/ext/json/json.c b/ext/json/json.c index db3fad98710..7231e647c3a 100644 --- a/ext/json/json.c +++ b/ext/json/json.c @@ -703,6 +703,8 @@ static PHP_FUNCTION(json_decode) return; } + JSON_G(error_code) = 0; + if (!str_len) { RETURN_NULL(); } diff --git a/ext/json/tests/bug54484.phpt b/ext/json/tests/bug54484.phpt new file mode 100644 index 00000000000..d698ab54164 --- /dev/null +++ b/ext/json/tests/bug54484.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #54484 (Empty string in json_decode doesn't reset json_last_error) +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(0) +int(0) +int(4) +int(0)