summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS5
-rw-r--r--Zend/tests/bug70179.phpt16
-rw-r--r--Zend/zend_vm_def.h3
-rw-r--r--Zend/zend_vm_execute.h9
4 files changed, 31 insertions, 2 deletions
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--
+<?php
+
+class X {
+ function __invoke() {
+ var_dump($this);
+ }
+}
+(new X)();
+
+?>
+--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) &&