Prevent bit shift count wrapping quirkiness on some CPUs for left shift

This commit is contained in:
Andrea Faulds 2014-08-19 20:00:40 +01:00
parent cb770cdc03
commit b3ba0f6ab0

View File

@ -1493,6 +1493,12 @@ ZEND_API int shift_left_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, 0);
return SUCCESS;
}
if (Z_LVAL_P(op2) < 0) {
zend_error(E_WARNING, "Bit shift by negative number");
ZVAL_FALSE(result);