summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2004-01-09 13:52:19 +0000
committerStanislav Malyshev <stas@php.net>2004-01-09 13:52:19 +0000
commite321eba06b24936cf6834d32c4aa050f9d16f16e (patch)
tree33d2529bd8935925e0030aac1aef2c375c7c7fd0
parent9e229aa09d6ee367a09686875472815372a66231 (diff)
downloadphp-git-e321eba06b24936cf6834d32c4aa050f9d16f16e.tar.gz
Fix Bug #26077 - memory leak when new() result is not assigned
and no constructor defined
-rw-r--r--Zend/zend_compile.c1
-rw-r--r--Zend/zend_execute.c5
2 files changed, 5 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 414d98e00f..788ba08890 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -918,6 +918,7 @@ void zend_do_free(znode *op1 TSRMLS_DC)
* proceeding INIT_FCALL_BY_NAME as unused
*/
if (opline->opcode == ZEND_JMP_NO_CTOR) {
+ opline->op1.u.EA.type |= EXT_TYPE_UNUSED;
(opline-1)->result.u.EA.type |= EXT_TYPE_UNUSED;
(opline+1)->op1.u.EA.type |= EXT_TYPE_UNUSED;
break;
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 62350865ad..4853d18d7a 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -3095,7 +3095,7 @@ int zend_new_handler(ZEND_OPCODE_HANDLER_ARGS)
object_init_ex(EX_T(EX(opline)->result.u.var).var.ptr, EX_T(EX(opline)->op1.u.var).class_entry);
EX_T(EX(opline)->result.u.var).var.ptr->refcount=1;
EX_T(EX(opline)->result.u.var).var.ptr->is_ref=1;
-
+
NEXT_OPCODE();
}
@@ -3731,6 +3731,9 @@ int zend_jmp_no_ctor_handler(ZEND_OPCODE_HANDLER_ARGS)
EX(fbc_constructor) = NULL;
if (constructor == NULL) {
+ if(EX(opline)->op1.u.EA.type & EXT_TYPE_UNUSED) {
+ zval_ptr_dtor(EX_T(EX(opline)->op1.u.var).var.ptr_ptr);
+ }
EX(opline) = op_array->opcodes + EX(opline)->op2.u.opline_num;
return 0; /* CHECK_ME */
} else {