summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>1999-11-17 17:21:15 +0000
committerAndi Gutmans <andi@php.net>1999-11-17 17:21:15 +0000
commit52045afb0881d645155515f2d492deb1d51cb2e2 (patch)
treebd48bf7d4e2eced09b774b01921585604f9554a9 /Zend
parent3150bd63e9472aacd84df531fcf477f829e4695a (diff)
downloadphp-git-52045afb0881d645155515f2d492deb1d51cb2e2.tar.gz
- If a function's return value is unused then don't create a ZEND_FREE
opcode but free it after the function call in zend_execute.
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_compile.c11
-rw-r--r--Zend/zend_execute.c3
2 files changed, 9 insertions, 5 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 9955453190..c5483d19ee 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -623,15 +623,16 @@ void do_free(znode *op1 CLS_DC)
{
if (op1->op_type==IS_TMP_VAR) {
zend_op *last_opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1];
- zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
if ((last_opline->opcode == ZEND_DO_FCALL) || (last_opline->opcode == ZEND_DO_FCALL_BY_NAME)) {
last_opline->result.u.EA.type |= EXT_TYPE_UNUSED;
- }
+ } else {
+ zend_op *opline = get_next_op(CG(active_op_array) CLS_CC);
- opline->opcode = ZEND_FREE;
- opline->op1 = *op1;
- SET_UNUSED(opline->op2);
+ opline->opcode = ZEND_FREE;
+ opline->op1 = *op1;
+ SET_UNUSED(opline->op2);
+ }
} else if (op1->op_type==IS_VAR) {
zend_op *opline = &CG(active_op_array)->opcodes[CG(active_op_array)->last-1];
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index a580c76c13..b4baddcb7c 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1472,6 +1472,9 @@ do_fcall_common:
if (object.ptr) {
object.ptr->refcount--;
}
+ if (opline->result.u.EA.type & EXT_TYPE_UNUSED) {
+ zendi_zval_dtor(Ts[opline->result.u.var].tmp_var);
+ }
} else if (function_state.function->type==ZEND_USER_FUNCTION) {
HashTable *calling_symbol_table;