mirror of
https://github.com/php/php-src.git
synced 2026-04-11 01:53:36 +02:00
Make division by zero error check more accurate
For division (rather than modulus) we should check the double value, otherwise the result might be zero after integer truncation, but not zero as a floating point value.
This commit is contained in:
@@ -7259,7 +7259,8 @@ ZEND_API zend_bool zend_binary_op_produces_error(uint32_t opcode, zval *op1, zva
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((opcode == ZEND_DIV || opcode == ZEND_MOD) && zval_get_long(op2) == 0) {
|
||||
if ((opcode == ZEND_MOD && zval_get_long(op2) == 0)
|
||||
|| (opcode == ZEND_DIV && zval_get_double(op2) == 0.0)) {
|
||||
/* Division by zero throws an error. */
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user