mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fixed bug #76717
Print INT_MIN as -INT_MAX-1 to avoid it getting parsed as a float literal due to integer overflow.
This commit is contained in:
parent
769d2d9b62
commit
1fd32e9c2f
3 changed files with 23 additions and 0 deletions
2
NEWS
2
NEWS
|
@ -37,6 +37,8 @@ PHP NEWS
|
||||||
custom wrapper). (Laruence)
|
custom wrapper). (Laruence)
|
||||||
. Fixed bug #77669 (Crash in extract() when overwriting extracted array).
|
. Fixed bug #77669 (Crash in extract() when overwriting extracted array).
|
||||||
(Nikita)
|
(Nikita)
|
||||||
|
. Fixed bug #76717 (var_export() does not create a parsable value for
|
||||||
|
PHP_INT_MIN). (Nikita)
|
||||||
|
|
||||||
07 Mar 2019, PHP 7.2.16
|
07 Mar 2019, PHP 7.2.16
|
||||||
|
|
||||||
|
|
14
ext/standard/tests/general_functions/bug76717.phpt
Normal file
14
ext/standard/tests/general_functions/bug76717.phpt
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
--TEST--
|
||||||
|
Bug #76717: var_export() does not create a parsable value for PHP_INT_MIN
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$min = eval('return '.var_export(PHP_INT_MIN, true).';');
|
||||||
|
$max = eval('return '.var_export(PHP_INT_MAX, true).';');
|
||||||
|
var_dump($min === PHP_INT_MIN);
|
||||||
|
var_dump($max === PHP_INT_MAX);
|
||||||
|
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
bool(true)
|
||||||
|
bool(true)
|
|
@ -459,6 +459,13 @@ again:
|
||||||
smart_str_appendl(buf, "NULL", 4);
|
smart_str_appendl(buf, "NULL", 4);
|
||||||
break;
|
break;
|
||||||
case IS_LONG:
|
case IS_LONG:
|
||||||
|
/* INT_MIN as a literal will be parsed as a float. Emit something like
|
||||||
|
* -9223372036854775807-1 to avoid this. */
|
||||||
|
if (Z_LVAL_P(struc) == ZEND_LONG_MIN) {
|
||||||
|
smart_str_append_long(buf, ZEND_LONG_MIN+1);
|
||||||
|
smart_str_appends(buf, "-1");
|
||||||
|
break;
|
||||||
|
}
|
||||||
smart_str_append_long(buf, Z_LVAL_P(struc));
|
smart_str_append_long(buf, Z_LVAL_P(struc));
|
||||||
break;
|
break;
|
||||||
case IS_DOUBLE:
|
case IS_DOUBLE:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue