]> granicus.if.org Git - php/commitdiff
- Fixed bug #27354 (Modulus operator crashes PHP).
authorDerick Rethans <derick@php.net>
Sun, 22 Feb 2004 20:02:26 +0000 (20:02 +0000)
committerDerick Rethans <derick@php.net>
Sun, 22 Feb 2004 20:02:26 +0000 (20:02 +0000)
Zend/zend_operators.c

index c83fd08e039127cd67f20c69c7c7d64d6cc7ebb2..08eb13398caf58c581d5b5341b235255237a250d 100644 (file)
@@ -836,6 +836,11 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
                return FAILURE;                 /* modulus by zero */
        }
 
+       if (abs(op2->value.lval) == 1) {
+               ZVAL_LONG(result, 0);
+               return SUCCESS;
+       }
+
        result->type = IS_LONG;
        result->value.lval = op1->value.lval % op2->value.lval;
        return SUCCESS;