com php-src: Prevent bit shift count wrapping quirkiness on some CPUs for right shift: Zend/zend_operators.c
| From: | ajf@php.net | Date: | Tue, 19 Aug 2014 19:21:23 +0000 |
| Subject: | com php-src: Prevent bit shift count wrapping quirkiness on some CPUs for right shift: Zend/zend_operators.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-81840@lists.php.net to get a copy of this message | ||
Commit: 38bc0a05c0bcf6008347c2297ce1f0a5607409d5
Author: Andrea Faulds <ajf@ajf.me> Sat, 16 Aug 2014 00:54:37 +0100
Parents: 2f5e508e39567ca577de34b8c6005e49ac1ee93c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=38bc0a05c0bcf6008347c2297ce1f0a5607409d5
Log:
Prevent bit shift count wrapping quirkiness on some CPUs for right shift
Changed paths:
M Zend/zend_operators..c
Diff:
diff --git a/Zend/zend_operators.c b/Zend/zend_operators..c
index 7d591f5..9821095 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -1519,6 +1519,12 @@ ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2
TSRMLS_DC)
op1_lval = Z_LVAL_P(op1);
}
+ /* prevent wrapping quirkiness on some processors where >> 64 + x == >> x */
+ if (Z_LVAL_P(op2) >= SIZEOF_LONG * 8) {
+ ZVAL_LONG(result, (Z_LVAL_P(op1) < 0) ? -1 : 0);
+ return SUCCESS;
+ }
+
if (Z_LVAL_P(op2) < 0) {
zend_error(E_WARNING, "Bit shift by negative number");
ZVAL_FALSE(result);