Skip to content

Commit

Permalink
Revert "Fix #79908: json_encode encodes negative zero as int"
Browse files Browse the repository at this point in the history
This reverts commit 717f1ed.
  • Loading branch information
cmb69 committed Jul 19, 2021
1 parent 26b1572 commit 2d2c001
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 17 deletions.
3 changes: 0 additions & 3 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions ext/json/json_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
12 changes: 0 additions & 12 deletions ext/json/tests/bug79908.phpt

This file was deleted.

0 comments on commit 2d2c001

Please sign in to comment.