summaryrefslogtreecommitdiff
path: root/Zend/zend_operators.c
diff options
context:
space:
mode:
authorMatt Wilmas <mattwil@php.net>2008-05-29 11:45:13 +0000
committerMatt Wilmas <mattwil@php.net>2008-05-29 11:45:13 +0000
commit87dca00a8e3a22ac0d988f417d94883b896eb88c (patch)
treef9e7003c1f37aece02472ff6f62779e066137358 /Zend/zend_operators.c
parent19322fc782af429938da8d3b421c0807cf1b848a (diff)
downloadphp-git-87dca00a8e3a22ac0d988f417d94883b896eb88c.tar.gz
MFH: Fixed overflow crash (at least on Windows) in div_function with LONG_MIN / -1
Diffstat (limited to 'Zend/zend_operators.c')
-rw-r--r--Zend/zend_operators.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c
index 6a905cef9d..08ea3b0df8 100644
--- a/Zend/zend_operators.c
+++ b/Zend/zend_operators.c
@@ -934,6 +934,10 @@ ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
zend_error(E_WARNING, "Division by zero");
ZVAL_BOOL(result, 0);
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 */
ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));