Skip to content

Commit 2d2c001

Browse files
committed
Revert "Fix #79908: json_encode encodes negative zero as int"
This reverts commit 717f1ed.
1 parent 26b1572 commit 2d2c001

File tree

3 files changed

+1
-17
lines changed

3 files changed

+1
-17
lines changed

NEWS

-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ PHP NEWS
3737
. Fixed bug #68471 (IntlDateFormatter fails for "GMT+00:00" timezone). (cmb)
3838
. Fixed bug #74264 (grapheme_strrpos() broken for negative offsets). (cmb)
3939

40-
- JSON:
41-
. Fixed bug #79908 (json_encode encodes negative zero as int). (cmb)
42-
4340
- OpenSSL:
4441
. Fixed bug #52093 (openssl_csr_sign truncates $serial). (cmb)
4542

ext/json/json_encoder.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ static inline void php_json_encode_double(smart_str *buf, double d, int options)
104104

105105
php_gcvt(d, (int)PG(serialize_precision), '.', 'e', num);
106106
len = strlen(num);
107-
if ((options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_DOUBLE_MAX_LENGTH - 2)
108-
|| (UNEXPECTED(len == 2 && num[0] == '-' && num[1] == '0'))) {
107+
if (options & PHP_JSON_PRESERVE_ZERO_FRACTION && strchr(num, '.') == NULL && len < PHP_DOUBLE_MAX_LENGTH - 2) {
109108
num[len++] = '.';
110109
num[len++] = '0';
111110
num[len] = '\0';

ext/json/tests/bug79908.phpt

-12
This file was deleted.

0 commit comments

Comments
 (0)