com php-src: Fixed memleak in SCCP: ext/opcache/Optimizer/sccp.c ext/opcache/tests/opt/sccp_021.phpt
| From: | Xinchen Hui | Date: | Tue, 12 Sep 2017 13:35:30 +0000 |
| Subject: | com php-src: Fixed memleak in SCCP: ext/opcache/Optimizer/sccp.c ext/opcache/tests/opt/sccp_021.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-99390@lists.php.net to get a copy of this message | ||
Commit: 07ed545abfb5a5caed6de3b8cf18930398759559
Author: Xinchen Hui <laruence@gmail.com> Tue, 12 Sep 2017 21:34:53 +0800
Parents: 0a98998b3c1ba9733c0ce24c28d930f0b16be87a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=07ed545abfb5a5caed6de3b8cf18930398759559
Log:
Fixed memleak in SCCP
Changed paths:
M ext/opcache/Optimizer/sccp.c
A ext/opcache/tests/opt/sccp_021.phpt
Diff:
diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c
index 7c15918..e0529e8 100644
--- a/ext/opcache/Optimizer/sccp.c
+++ b/ext/opcache/Optimizer/sccp.c
@@ -1347,7 +1347,6 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
SKIP_IF_TOP(data);
if (ct_eval_fetch_dim(&tmp, op1, op2, 0) == SUCCESS) {
-
if (IS_BOT(data)) {
dup_partial_array(&zv, op1);
ct_eval_del_array_elem(&zv, op2);
@@ -1355,6 +1354,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
if (zend_optimizer_eval_binary_op(&tmp,
zend_compound_assign_to_binary_op(opline->opcode), &tmp, data) != SUCCESS) {
SET_RESULT_BOT(result);
SET_RESULT_BOT(op1);
+ zval_ptr_dtor_nogc(&tmp);
break;
}
@@ -1368,9 +1368,11 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
if (ct_eval_assign_dim(&zv, &tmp, op2) == SUCCESS) {
SET_RESULT(result, &tmp);
SET_RESULT(op1, &zv);
+ zval_ptr_dtor_nogc(&tmp);
zval_ptr_dtor_nogc(&zv);
break;
}
+ zval_ptr_dtor_nogc(&tmp);
zval_ptr_dtor_nogc(&zv);
}
}
@@ -1384,7 +1386,6 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
SKIP_IF_TOP(data);
if (ct_eval_fetch_obj(&tmp, op1, op2) == SUCCESS) {
-
if (IS_BOT(data)) {
dup_partial_object(&zv, op1);
ct_eval_del_obj_prop(&zv, op2);
@@ -1392,6 +1393,7 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
if (zend_optimizer_eval_binary_op(&tmp,
zend_compound_assign_to_binary_op(opline->opcode), &tmp, data) != SUCCESS) {
SET_RESULT_BOT(result);
SET_RESULT_BOT(op1);
+ zval_ptr_dtor_nogc(&tmp);
break;
}
@@ -1401,9 +1403,11 @@ static void sccp_visit_instr(scdf_ctx *scdf, zend_op *opline, zend_ssa_op
*ssa_o
if (ct_eval_assign_obj(&zv, &tmp, op2) == SUCCESS) {
SET_RESULT(result, &tmp);
SET_RESULT(op1, &zv);
+ zval_ptr_dtor_nogc(&tmp);
zval_ptr_dtor_nogc(&zv);
break;
}
+ zval_ptr_dtor_nogc(&tmp);
zval_ptr_dtor_nogc(&zv);
}
}
diff --git a/ext/opcache/tests/opt/sccp_021.phpt b/ext/opcache/tests/opt/sccp_021.phpt
new file mode 100644
index 0000000..27d1c91
--- /dev/null
+++ b/ext/opcache/tests/opt/sccp_021.phpt
@@ -0,0 +1,30 @@
+--TEST--
+SCCP 020: Memleak
+--INI--
+opcache.enable=1
+opcache.enable_cli=1
+opcache.optimization_level=-1
+;opcache.opt_debug_level=0x20000
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+class A {
+ public function memleak($num_tokens) {
+ $queries = array();
+ for ( $i = 0; $i < $num_tokens; ++$i ) {
+ if ( 0 < $i )
+ $queries[$i] = $queries[$i - 1] . '&';
+ else
+ $queries[$i] = '';
+
+ $queries[$i] .= $query_token;
+ }
+
+ return;
+ }
+}
+okey
+?>
+--EXPECT--
+okey