com php-src: Fix the same leak with %=: Zend/tests/comp ound_assign_with_numeric_strings.phpt Zend/tests/co mpound_shift_string_error.phpt
Zend/zend_operators .c

From: Date: Wed, 07 Jan 2015 22:21:12 +0000
Subject: com php-src: Fix the same leak with %=: Zend/tests/comp ound_assign_with_numeric_strings.phpt Zend/tests/co mpound_shift_string_error.phpt
Zend/zend_operators .c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-84019@lists.php.net to get a copy of this message
Commit: 3e826c97366044991ae3c892e00d607449f69d66 Author: Nikita Popov <nikic@php.net> Wed, 7 Jan 2015 23:21:12 +0100 Parents: 98c2ceacf81116065028cb18a918adafe7a38ee2 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3e826c97366044991ae3c892e00d607449f69d66 Log: Fix the same leak with %= Changed paths: A Zend/tests/compound_assign_with_numeric_strings.phpt D Zend/tests/compound_shift_string_error.phpt M Zend/zend_operators.c Diff: diff --git a/Zend/tests/compound_assign_with_numeric_strings.phpt b/Zend/tests/compound_assign_with_numeric_strings.phpt new file mode 100644 index 0000000..803650c --- /dev/null +++ b/Zend/tests/compound_assign_with_numeric_strings.phpt @@ -0,0 +1,41 @@ +--TEST-- +Error cases of compound shift assignment on strings +--FILE-- +<?php + +$n = "65"; +$n <<= $n; +var_dump($n); + +$n = "-1"; +$n <<= $n; +var_dump($n); + +$n = "65"; +$n >>= $n; +var_dump($n); + +$n = "-1"; +$n >>= $n; +var_dump($n); + +$n = "0"; +$n %= $n; +var_dump($n); + +$n = "-1"; +$n %= $n; +var_dump($n); +--EXPECTF-- +int(0) + +Warning: Bit shift by negative number in %s on line %d +bool(false) +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) diff --git a/Zend/tests/compound_shift_string_error.phpt b/Zend/tests/compound_shift_string_error.phpt deleted file mode 100644 index 7f01962..0000000 --- a/Zend/tests/compound_shift_string_error.phpt +++ /dev/null @@ -1,31 +0,0 @@ ---TEST-- -Error cases of compound shift assignment on strings ---FILE-- -<?php - -$n = "65"; -$n <<= $n; -var_dump($n); - -$n = "-1"; -$n <<= $n; -var_dump($n); - -$n = "65"; -$n >>= $n; -var_dump($n); - -$n = "-1"; -$n >>= $n; -var_dump($n); - -?> ---EXPECTF-- -int(0) - -Warning: Bit shift by negative number in %s on line %d -bool(false) -int(0) - -Warning: Bit shift by negative number in %s on line %d -bool(false) diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 31d92c4..0b1b9f2 100644 --- a/Zend/zend_operators.c +++ b/Zend/zend_operators.c @@ -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; }

« previous php.cvs (#84019) next »