diff options
| author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2013-12-11 08:50:53 +0100 |
|---|---|---|
| committer | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2013-12-11 08:50:53 +0100 |
| commit | bec62af14145c4c636716fc54465fc2f8c5d00b4 (patch) | |
| tree | 88251182fd3e24559824c311921d4533783db3ed /Zend/zend_operators.h | |
| parent | 41cd53329871cb99799cd9a8f76151312be2e960 (diff) | |
| parent | 8f1fee61e2f0c24fd46d0ecbc6ded5c68bae7d6e (diff) | |
| download | php-git-bec62af14145c4c636716fc54465fc2f8c5d00b4.tar.gz | |
Merge branch 'PHP-5.4' into PHP-5.5
Diffstat (limited to 'Zend/zend_operators.h')
| -rw-r--r-- | Zend/zend_operators.h | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index 6e52de0698..815cf582b6 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -640,13 +640,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 |
