mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
MFH: Fixed overflow crash (at least on Windows) in div_function with LONG_MIN / -1
This commit is contained in:
parent
19322fc782
commit
87dca00a8e
1 changed files with 4 additions and 0 deletions
|
@ -934,6 +934,10 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
|
||||||
zend_error(E_WARNING, "Division by zero");
|
zend_error(E_WARNING, "Division by zero");
|
||||||
ZVAL_BOOL(result, 0);
|
ZVAL_BOOL(result, 0);
|
||||||
return FAILURE; /* division by zero */
|
return FAILURE; /* division by zero */
|
||||||
|
} else if (Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == LONG_MIN) {
|
||||||
|
/* Prevent overflow error/crash */
|
||||||
|
ZVAL_DOUBLE(result, (double) LONG_MIN / -1);
|
||||||
|
return SUCCESS;
|
||||||
}
|
}
|
||||||
if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */
|
if (Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0) { /* integer */
|
||||||
ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));
|
ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue