com php-src: Fixed some incorrect zval_dtor() usages: Zend/tests/gc_038.phpt Zend/zend_operators.c

From: Date: Wed, 04 Jul 2018 20:48:39 +0000
Subject: com php-src: Fixed some incorrect zval_dtor() usages: Zend/tests/gc_038.phpt Zend/zend_operators.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102406@lists.php.net to get a copy of this message
Commit: 5898583e94462a6808b981b06dece2316979c8c1 Author: Dmitry Stogov <dmitry@zend.com> Wed, 4 Jul 2018 23:48:39 +0300 Parents: 3a8f26060c44b86145f332e87c53668cac58a6d0 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=5898583e94462a6808b981b06dece2316979c8c1 Log: Fixed some incorrect zval_dtor() usages Changed paths: A Zend/tests/gc_038.phpt M Zend/zend_operators.c Diff: diff --git a/Zend/tests/gc_038.phpt b/Zend/tests/gc_038.phpt new file mode 100644 index 0000000..7bb7b7a --- /dev/null +++ b/Zend/tests/gc_038.phpt @@ -0,0 +1,133 @@ +--TEST-- +GC 038: Garbage created by compound assignment operators (e.g. +=) +--INI-- +zend.enable_gc = 1 +--FILE-- +<?php +function test_add() { + $x = new stdClass; + $x->x= $x; + @$x += 5; + $n = gc_collect_cycles(); + echo "+=\t$n\n"; +} +test_add(); + +function test_sub() { + $x = new stdClass; + $x->x= $x; + @$x -= 5; + $n = gc_collect_cycles(); + echo "-=\t$n\n"; +} +test_sub(); + +function test_mul() { + $x = new stdClass; + $x->x= $x; + @$x *= 5; + $n = gc_collect_cycles(); + echo "*=\t$n\n"; +} +test_mul(); + +function test_div() { + $x = new stdClass; + $x->x= $x; + @$x /= 5; + $n = gc_collect_cycles(); + echo "/=\t$n\n"; +} +test_div(); + +function test_mod() { + $x = new stdClass; + $x->x= $x; + @$x %= 5; + $n = gc_collect_cycles(); + echo "%=\t$n\n"; +} +test_mod(); + +function test_sl() { + $x = new stdClass; + $x->x= $x; + @$x <<= 5; + $n = gc_collect_cycles(); + echo "<<=\t$n\n"; +} +test_sl(); + +function test_sr() { + $x = new stdClass; + $x->x= $x; + @$x >>= 5; + $n = gc_collect_cycles(); + echo ">>=\t$n\n"; +} +test_sr(); + +function test_or() { + $x = new stdClass; + $x->x= $x; + @$x |= 1; + $n = gc_collect_cycles(); + echo "|=\t$n\n"; +} +test_or(); + +function test_and() { + $x = new stdClass; + $x->x= $x; + @$x &= 1; + $n = gc_collect_cycles(); + echo "&=\t$n\n"; +} +test_and(); + +function test_xor() { + $x = new stdClass; + $x->x= $x; + @$x ^= 1; + $n = gc_collect_cycles(); + echo "^=\t$n\n"; +} +test_xor(); + +function test_pow() { + $x = new stdClass; + $x->x= $x; + @$x **= 1; + $n = gc_collect_cycles(); + echo "**=\t$n\n"; +} +test_pow(); + +class Y { + function __toString() { + return "y"; + } +} +function test_concat() { + $x = new Y; + $x->x= $x; + @$x .= "x"; + $n = gc_collect_cycles(); + echo ".=\t$n\n"; +} +test_concat(); +?> +--EXPECT-- ++= 1 +-= 1 +*= 1 +/= 1 +%= 1 +<<= 1 +>>= 1 +|= 1 +&= 1 +^= 1 +**= 1 +.= 1 + diff --git a/Zend/zend_operators.c b/Zend/zend_operators.c index 333bce5..1cf1e7f 100644 --- a/Zend/zend_operators..c +++ b/Zend/zend_operators.c @@ -199,7 +199,7 @@ try_again: if (check && UNEXPECTED(EG(exception))) { return; } - zval_dtor(op); + zval_ptr_dtor(op); if (Z_TYPE(dst) == IS_LONG || Z_TYPE(dst) == IS_DOUBLE) { ZVAL_COPY_VALUE(op, &dst); @@ -1305,7 +1305,7 @@ ZEND_API int ZEND_FASTCALL mod_function(zval *result, zval *op1, zval *op2) /* { } if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } if (op2_lval == -1) { @@ -1505,7 +1505,7 @@ ZEND_API int ZEND_FASTCALL bitwise_or_function(zval *result, zval *op1, zval *op } if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, op1_lval | op2_lval); return SUCCESS; @@ -1583,7 +1583,7 @@ ZEND_API int ZEND_FASTCALL bitwise_and_function(zval *result, zval *op1, zval *o } if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, op1_lval & op2_lval); return SUCCESS; @@ -1661,7 +1661,7 @@ ZEND_API int ZEND_FASTCALL bitwise_xor_function(zval *result, zval *op1, zval *o } if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, op1_lval ^ op2_lval); return SUCCESS; @@ -1678,7 +1678,7 @@ ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op if (UNEXPECTED((zend_ulong)op2_lval >= SIZEOF_ZEND_LONG * 8)) { if (EXPECTED(op2_lval > 0)) { if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, 0); return SUCCESS; @@ -1696,7 +1696,7 @@ ZEND_API int ZEND_FASTCALL shift_left_function(zval *result, zval *op1, zval *op } if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, op1_lval << op2_lval); @@ -1714,7 +1714,7 @@ ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *o if (UNEXPECTED((zend_ulong)op2_lval >= SIZEOF_ZEND_LONG * 8)) { if (EXPECTED(op2_lval > 0)) { if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, (op1_lval < 0) ? -1 : 0); return SUCCESS; @@ -1732,7 +1732,7 @@ ZEND_API int ZEND_FASTCALL shift_right_function(zval *result, zval *op1, zval *o } if (op1 == result) { - zval_dtor(result); + zval_ptr_dtor(result); } ZVAL_LONG(result, op1_lval >> op2_lval); @@ -1794,7 +1794,7 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) / if (UNEXPECTED(Z_STRLEN_P(op1) == 0)) { if (EXPECTED(result != op2)) { if (result == orig_op1) { - zval_dtor(orig_op1); + i_zval_ptr_dtor(result ZEND_FILE_LINE_CC); } ZVAL_COPY(result, op2); } @@ -1825,7 +1825,7 @@ ZEND_API int ZEND_FASTCALL concat_function(zval *result, zval *op1, zval *op2) / result_str = zend_string_alloc(result_len, 0); memcpy(ZSTR_VAL(result_str), Z_STRVAL_P(op1), op1_len); if (result == orig_op1) { - zval_dtor(orig_op1); + i_zval_ptr_dtor(result ZEND_FILE_LINE_CC); } }

« previous php.cvs (#102406) next »