com php-src: Fix block pass leaks: ext/opcache/Optimizer/block _pass.c ext/opcache/tests/block_pass_001.phpt
| From: | Nikita Popov | Date: | Thu, 10 Nov 2016 21:28:32 +0000 |
| Subject: | com php-src: Fix block pass leaks: ext/opcache/Optimizer/block _pass.c ext/opcache/tests/block_pass_001.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95705@lists.php.net to get a copy of this message | ||
Commit: 8106c01afc6ce34205196f2c905a2a7a74a69248
Author: Nikita Popov <nikic@php.net> Thu, 10 Nov 2016 21:42:05 +0100
Parents: 62af7e0db89a18bb9ff61589fb91cb7a718c1820
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8106c01afc6ce34205196f2c905a2a7a74a69248
Log:
Fix block pass leaks
Changed paths:
M ext/opcache/Optimizer/block_pass.c
M ext/opcache/tests/block_pass_001.phpt
Diff:
diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c
index aea670b..77b02cc 100644
--- a/ext/opcache/Optimizer/block_pass.c
+++ b/ext/opcache/Optimizer/block_pass.c
@@ -254,12 +254,9 @@ static void zend_optimize_block(zend_basic_block *block, zend_op_array
*op_array
src = VAR_SOURCE(opline->op1);
if (src &&
(src->opcode == ZEND_BOOL || src->opcode == ZEND_BOOL_NOT)) {
- /* T = BOOL(X), FREE(T) => NOP */
- if (ZEND_OP1_TYPE(src) == IS_CONST) {
- literal_dtor(&ZEND_OP1_LITERAL(src));
- }
+ /* T = BOOL(X), FREE(T) => T = BOOL(X) */
+ /* The remaining BOOL is removed by a separate optimization */
VAR_SOURCE(opline->op1) = NULL;
- MAKE_NOP(src);
MAKE_NOP(opline);
}
} else if (opline->op1_type == IS_VAR) {
@@ -1660,7 +1657,7 @@ static void zend_t_usage(zend_cfg *cfg, zend_op_array *op_array, zend_bitset
use
if (ZEND_OP1_TYPE(opline) == IS_CV) {
opline->opcode = ZEND_CHECK_VAR;
SET_UNUSED(opline->result);
- } else if (ZEND_OP1_TYPE(opline) == IS_TMP_VAR) {
+ } else if (ZEND_OP1_TYPE(opline) & (IS_TMP_VAR|IS_VAR)) {
opline->opcode = ZEND_FREE;
SET_UNUSED(opline->result);
} else {
diff --git a/ext/opcache/tests/block_pass_001.phpt b/ext/opcache/tests/block_pass_001.phpt
index 8a1b691..556e76f 100644
--- a/ext/opcache/tests/block_pass_001.phpt
+++ b/ext/opcache/tests/block_pass_001.phpt
@@ -1,8 +1,10 @@
--TEST--
-Block pass: Don't suppress undefined variable notice
+Block pass: Bugs in BOOL/QM_ASSIGN elision
--FILE--
<?php
(bool) (true ? $x : $y);
+(bool) (true ? new stdClass : null);
+(bool) new stdClass;
?>
--EXPECTF--
Notice: Undefined variable: x in %s on line %d