overflown values).
- Add --ri switch to CLI which allows to check extension information. (Marcus)
- Added tidyNode::getParent() method (John, Nuno)
- Fixed zend_llist_remove_tail (Michael Wallner, Dmitry)
+- Fixed bug #40503 (json_encode() value corruption on 32bit systems with
+ overflown values). (Ilia)
- Fixed bug #40467 (Partial SOAP request sent when XSD sequence or choice
include minOccurs=0). (Dmitry)
- Fixed bug #40465 (Ensure that all PHP elements are printed by var_dump).
}
break;
case IS_LONG:
- smart_str_append_long(buf, Z_LVAL_P(val));
+ smart_str_append_long(buf, Z_LVAL_P(val));
break;
case IS_DOUBLE:
{
int len;
double dbl = Z_DVAL_P(val);
- if (!zend_isinf(dbl) && !zend_isnan(dbl))
- {
- len = spprintf(&d, 0, "%.9g", dbl);
- if (d)
- {
- smart_str_appendl(buf, d, len);
- efree(d);
- }
+ if (!zend_isinf(dbl) && !zend_isnan(dbl)) {
+ len = spprintf(&d, 0, "%.9g", dbl);
+ if (d) {
+ if (dbl > LONG_MAX && !memchr(d, '.', len)) {
+ smart_str_append_unsigned(buf, (unsigned long)Z_DVAL_P(val));
+ } else {
+ smart_str_appendl(buf, d, len);
+ }
+ efree(d);
+ }
}
else
{
--- /dev/null
+--TEST--
+Bug #40503 (json_encode() value corruption on 32bit systems with overflown values)
+--SKIPIF--
+<?php if (!extension_loaded("json")) print "skip"; ?>
+--FILE--
+<?php
+function show_eq($x,$y) {
+ echo "$x ". ($x==$y ? "==" : "!=") ." $y\n";
+}
+
+$value = 0x7FFFFFFF; #2147483647;
+show_eq("$value", json_encode($value));
+$value++;
+show_eq("$value", json_encode($value));
+
+?>
+--EXPECT--
+2147483647 == 2147483647
+2147483648 == 2147483648