From 2d2c001ca51f8f332e5ac330729e81f2f14ccbd6 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Tue, 20 Jul 2021 00:25:11 +0200 Subject: [PATCH] Revert "Fix #79908: json_encode encodes negative zero as int" This reverts commit 717f1ed5e4b4b2083907dd085e66b377edad24b7. --- NEWS | 3 --- ext/json/json_encoder.c | 3 +-- ext/json/tests/bug79908.phpt | 12 ------------ 3 files changed, 1 insertion(+), 17 deletions(-) delete mode 100644 ext/json/tests/bug79908.phpt diff --git a/NEWS b/NEWS index a60fdf79234..40a01fb4b63 100644 --- a/NEWS +++ b/NEWS @@ -37,9 +37,6 @@ PHP NEWS . Fixed bug #68471 (IntlDateFormatter fails for "GMT+00:00" timezone). (cmb) . Fixed bug #74264 (grapheme_strrpos() broken for negative offsets). (cmb) -- JSON: - . Fixed bug #79908 (json_encode encodes negative zero as int). (cmb) - - OpenSSL: . Fixed bug #52093 (openssl_csr_sign truncates $serial). (cmb) diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index d56cc246951..c0fcbe32820 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -104,8 +104,7 @@ static inline void php_json_encode_double(smart_str *buf, double d, int options) php_gcvt(d, (int)PG(serialize_precision), '.', 'e', num); len = strlen(num); - if ((options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_DOUBLE_MAX_LENGTH - 2) - || (UNEXPECTED(len == 2 && num[0] == '-' && num[1] == '0'))) { + if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_DOUBLE_MAX_LENGTH - 2) { num[len++] = '.'; num[len++] = '0'; num[len] = '\0'; diff --git a/ext/json/tests/bug79908.phpt b/ext/json/tests/bug79908.phpt deleted file mode 100644 index b2aea31069a..00000000000 --- a/ext/json/tests/bug79908.phpt +++ /dev/null @@ -1,12 +0,0 @@ ---TEST-- -Bug #79908 (json_encode encodes negative zero as int) ---SKIPIF-- - ---FILE-- - ---EXPECT-- -string(4) "-0.0"