From a7dfb3155777e3e367d125e8b0c73d3e577678a2 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 1 Jun 2011 09:44:38 +0000 Subject: [PATCH] Fixed bug #54484 (Empty string in json_decode doesn't reset json_last_error()). --- ext/json/json.c | 2 ++ ext/json/tests/bug54484.phpt | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 ext/json/tests/bug54484.phpt diff --git a/ext/json/json.c b/ext/json/json.c index db3fad9871..7231e647c3 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 0000000000..d698ab5416 --- /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) -- 2.40.0