Skip to content

Commit 6818ca3

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents f8850cc + 1fd32e9 commit 6818ca3

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ PHP NEWS
3131
custom wrapper). (Laruence)
3232
. Fixed bug #77669 (Crash in extract() when overwriting extracted array).
3333
(Nikita)
34+
. Fixed bug #76717 (var_export() does not create a parsable value for
35+
PHP_INT_MIN). (Nikita)
3436

3537
07 Mar 2019, PHP 7.3.3
3638

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #76717: var_export() does not create a parsable value for PHP_INT_MIN
3+
--FILE--
4+
<?php
5+
6+
$min = eval('return '.var_export(PHP_INT_MIN, true).';');
7+
$max = eval('return '.var_export(PHP_INT_MAX, true).';');
8+
var_dump($min === PHP_INT_MIN);
9+
var_dump($max === PHP_INT_MAX);
10+
11+
?>
12+
--EXPECT--
13+
bool(true)
14+
bool(true)

ext/standard/var.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,13 @@ PHPAPI void php_var_export_ex(zval *struc, int level, smart_str *buf) /* {{{ */
455455
smart_str_appendl(buf, "NULL", 4);
456456
break;
457457
case IS_LONG:
458+
/* INT_MIN as a literal will be parsed as a float. Emit something like
459+
* -9223372036854775807-1 to avoid this. */
460+
if (Z_LVAL_P(struc) == ZEND_LONG_MIN) {
461+
smart_str_append_long(buf, ZEND_LONG_MIN+1);
462+
smart_str_appends(buf, "-1");
463+
break;
464+
}
458465
smart_str_append_long(buf, Z_LVAL_P(struc));
459466
break;
460467
case IS_DOUBLE:

0 commit comments

Comments
 (0)