]> granicus.if.org Git - php/commitdiff
Fix the same leak with %=
authorNikita Popov <nikic@php.net>
Wed, 7 Jan 2015 22:21:12 +0000 (23:21 +0100)
committerNikita Popov <nikic@php.net>
Wed, 7 Jan 2015 22:21:12 +0000 (23:21 +0100)
Zend/tests/compound_assign_with_numeric_strings.phpt [moved from Zend/tests/compound_shift_string_error.phpt with 74% similarity]
Zend/zend_operators.c

similarity index 74%
rename from Zend/tests/compound_shift_string_error.phpt
rename to Zend/tests/compound_assign_with_numeric_strings.phpt
index 7f01962451c6e725f657e0551ee83d07792d31dd..803650cb02445ca20412a0fd44516f14b1e3d5c7 100644 (file)
@@ -19,7 +19,13 @@ $n = "-1";
 $n >>= $n;
 var_dump($n);
 
-?>
+$n = "0";
+$n %= $n;
+var_dump($n);
+
+$n = "-1";
+$n %= $n;
+var_dump($n);
 --EXPECTF--
 int(0)
 
@@ -29,3 +35,7 @@ int(0)
 
 Warning: Bit shift by negative number in %s on line %d
 bool(false)
+
+Warning: Division by zero in %s on line %d
+bool(false)
+int(0)
index 31d92c47113dd2295de9199578c5b83d2796c9c1..0b1b9f2188cd15cba28c71ec019e0446087ba78a 100644 (file)
@@ -1143,6 +1143,10 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2) /* {{{ */
        zend_long op1_lval, op2_lval;
 
        convert_op1_op2_long(op1, op1_lval, op2, op2_lval, ZEND_MOD, mod_function);
+
+       if (op1 == result) {
+               zval_dtor(result);
+       }
        
        if (op2_lval == 0) {
                zend_error(E_WARNING, "Division by zero");
@@ -1156,9 +1160,6 @@ ZEND_API int mod_function(zval *result, zval *op1, zval *op2) /* {{{ */
                return SUCCESS;
        }
 
-       if (op1 == result) {
-               zval_dtor(result);
-       }
        ZVAL_LONG(result, op1_lval % op2_lval);
        return SUCCESS;
 }