diff --git a/NEWS b/NEWS index bb2f13f5efb..65815160536 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ PHP NEWS . Fixed bug #74149 (static embed SAPI linkage error). (krakjoe) . Fixed bug #73370 (falsely exits with "Out of Memory" when using USE_ZEND_ALLOC=0). (Nikita) + . Fixed bug #73960 (Leak with instance method calling static method with + referenced return). (Nikita) - Date: . Fixed bug #72096 (Swatch time value incorrect for dates before 1970). (mcq8) diff --git a/Zend/tests/bug73960.phpt b/Zend/tests/bug73960.phpt new file mode 100644 index 00000000000..533c87afb02 --- /dev/null +++ b/Zend/tests/bug73960.phpt @@ -0,0 +1,16 @@ +--TEST-- +Bug #73960: Leak with instance method calling static method with referenced return +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + string(3) "one" +} diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index aa8d5f913e8..09b58959b61 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -81,6 +81,10 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval return variable_ptr; } if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) { + if (value_type == IS_VAR && ref) { + ZEND_ASSERT(GC_REFCOUNT(ref) > 1); + --GC_REFCOUNT(ref); + } return variable_ptr; } garbage = Z_COUNTED_P(variable_ptr);