Skip to content

Commit a9fd944

Browse files
committed
Deal with MOD op on it's own due to it's requirements
1 parent 107493b commit a9fd944

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Zend/zend_compile.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9997,15 +9997,21 @@ ZEND_API bool zend_binary_op_produces_error(uint32_t opcode, const zval *op1, co
99979997

99989998
/* Operation which cast float/float-strings to integers might produce incompatible float to int errors */
99999999
if (opcode == ZEND_SL || opcode == ZEND_SR || opcode == ZEND_BW_OR
10000-
|| opcode == ZEND_BW_AND || opcode == ZEND_BW_XOR || opcode == ZEND_MOD) {
10000+
|| opcode == ZEND_BW_AND || opcode == ZEND_BW_XOR) {
1000110001
return !zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2);
1000210002
}
1000310003

10004-
if ((opcode == ZEND_MOD && zval_get_long(op2) == 0)
10005-
|| (opcode == ZEND_DIV && zval_get_double(op2) == 0.0)) {
10004+
if (opcode == ZEND_DIV && zval_get_double(op2) == 0.0) {
1000610005
/* Division by zero throws an error. */
1000710006
return 1;
1000810007
}
10008+
10009+
/* Mod is an operation that will cast float/float-strings to integers which might
10010+
produce float to int incompatible errors, and also cannot be divided by 0 */
10011+
if (opcode == ZEND_MOD) {
10012+
return !zend_is_op_long_compatible(op1) || !zend_is_op_long_compatible(op2) || zval_get_long(op2) == 0;
10013+
}
10014+
1000910015
if ((opcode == ZEND_POW) && zval_get_double(op1) == 0 && zval_get_double(op2) < 0) {
1001010016
/* 0 ** (<0) throws a division by zero error. */
1001110017
return 1;

0 commit comments

Comments
 (0)