From 2d6f0e4584375c90a895fed4074d579f364aa347 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Sat, 1 Aug 2015 20:35:56 +0200 Subject: [PATCH] Fix bug #70179 ($this refcount issue) --- NEWS | 5 +++-- Zend/tests/bug70179.phpt | 16 ++++++++++++++++ Zend/zend_vm_def.h | 3 +++ Zend/zend_vm_execute.h | 9 +++++++++ 4 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 Zend/tests/bug70179.phpt diff --git a/NEWS b/NEWS index 39a4b62da6..5ad8082860 100644 --- a/NEWS +++ b/NEWS @@ -11,8 +11,9 @@ PHP NEWS . Fixed bug #70106 (Inheritance by anonymous class). (Bob) . Fixed bug #69674 (SIGSEGV array.c:953). (cmb) . Fixed bug #70164 (__COMPILER_HALT_OFFSET__ under namespace is not defined). - (Bob)) - . Fixed Bug #70108 (sometimes empty $_SERVER['QUERY_STRING']). (Anatol) + (Bob) + . Fixed bug #70108 (sometimes empty $_SERVER['QUERY_STRING']). (Anatol) + . Fixed bug #70179 ($this refcount issue). (Bob) - Curl: . Fixed bug #70163 (curl_setopt_array() type confusion). (Laruence) diff --git a/Zend/tests/bug70179.phpt b/Zend/tests/bug70179.phpt new file mode 100644 index 0000000000..a5bdb98805 --- /dev/null +++ b/Zend/tests/bug70179.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #70179 ($this refcount issue) +--FILE-- + +--EXPECT-- +object(X)#1 (0) { +} diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index f77e495fa2..8537a6a178 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -3250,6 +3250,9 @@ ZEND_VM_C_LABEL(try_function_name): ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT); GC_REFCOUNT(fbc->common.prototype)++; call_info |= ZEND_CALL_CLOSURE; + } else { + call_info |= ZEND_CALL_RELEASE_THIS; + GC_REFCOUNT(object)++; /* For $this pointer */ } FREE_OP2(); } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 950353c9a2..527de7d196 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2019,6 +2019,9 @@ try_function_name: ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT); GC_REFCOUNT(fbc->common.prototype)++; call_info |= ZEND_CALL_CLOSURE; + } else { + call_info |= ZEND_CALL_RELEASE_THIS; + GC_REFCOUNT(object)++; /* For $this pointer */ } } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && @@ -2438,6 +2441,9 @@ try_function_name: ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT); GC_REFCOUNT(fbc->common.prototype)++; call_info |= ZEND_CALL_CLOSURE; + } else { + call_info |= ZEND_CALL_RELEASE_THIS; + GC_REFCOUNT(object)++; /* For $this pointer */ } } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && @@ -2690,6 +2696,9 @@ try_function_name: ZEND_ASSERT(GC_TYPE(fbc->common.prototype) == IS_OBJECT); GC_REFCOUNT(fbc->common.prototype)++; call_info |= ZEND_CALL_CLOSURE; + } else { + call_info |= ZEND_CALL_RELEASE_THIS; + GC_REFCOUNT(object)++; /* For $this pointer */ } zval_ptr_dtor_nogc(free_op2); } else if (EXPECTED(Z_TYPE_P(function_name) == IS_ARRAY) && -- 2.40.0