mirror of
https://github.com/php/php-src.git
synced 2024-09-24 03:17:26 +00:00
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: Zend: fix overflow handling bug in non-x86 fast_add_function()
This commit is contained in:
commit
1dafdaa31b
@ -643,13 +643,18 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o
|
||||
"n"(ZVAL_OFFSETOF_TYPE)
|
||||
: "rax","cc");
|
||||
#else
|
||||
Z_LVAL_P(result) = Z_LVAL_P(op1) + Z_LVAL_P(op2);
|
||||
/*
|
||||
* 'result' may alias with op1 or op2, so we need to
|
||||
* ensure that 'result' is not updated until after we
|
||||
* have read the values of op1 and op2.
|
||||
*/
|
||||
|
||||
if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK)
|
||||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) {
|
||||
&& (Z_LVAL_P(op1) & LONG_SIGN_MASK) != ((Z_LVAL_P(op1) + Z_LVAL_P(op2)) & LONG_SIGN_MASK))) {
|
||||
Z_DVAL_P(result) = (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2);
|
||||
Z_TYPE_P(result) = IS_DOUBLE;
|
||||
} else {
|
||||
Z_LVAL_P(result) = Z_LVAL_P(op1) + Z_LVAL_P(op2);
|
||||
Z_TYPE_P(result) = IS_LONG;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user