]> granicus.if.org Git - php/commitdiff
Better throw an exception in intdiv() for PHP_INT_MIN/-1
authorBob Weinand <bobwei9@hotmail.com>
Sat, 18 Apr 2015 13:50:29 +0000 (15:50 +0200)
committerBob Weinand <bobwei9@hotmail.com>
Sat, 18 Apr 2015 13:50:29 +0000 (15:50 +0200)
ext/standard/math.c

index cff798c9fbd1a9319cd7ba8ae9345cfe16d9c845..a3685c00b93410a768a3252f580fc93d3d59e920 100644 (file)
@@ -1458,7 +1458,8 @@ PHP_FUNCTION(intdiv)
        } else if (divisor == -1 && numerator == ZEND_LONG_MIN) {
                /* Prevent overflow error/crash
                   We don't return a float here as that violates function contract */
-               RETURN_LONG(0);
+               zend_throw_exception_ex(NULL, 0, "Division of PHP_INT_MIN by -1 is not an integer");
+               return;
        }
 
        RETURN_LONG(numerator/divisor);