Skip to content

Commit 29ee3e3

Browse files
committed
Fixed bug #73960
1 parent c398198 commit 29ee3e3

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ PHP NEWS
55
- Core:
66
. Fixed bug #73370 (falsely exits with "Out of Memory" when using
77
USE_ZEND_ALLOC=0). (Nikita)
8+
. Fixed bug #73960 (Leak with instance method calling static method with
9+
referenced return). (Nikita)
810

911
- Date:
1012
. Fixed bug #72096 (Swatch time value incorrect for dates before 1970). (mcq8)

Zend/tests/bug73960.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #73960: Leak with instance method calling static method with referenced return
3+
--FILE--
4+
<?php
5+
6+
$value = 'one';
7+
$array = array($value);
8+
$array = $ref =& $array;
9+
var_dump($array);
10+
11+
?>
12+
--EXPECT--
13+
array(1) {
14+
[0]=>
15+
string(3) "one"
16+
}

Zend/zend_execute.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
7979
return variable_ptr;
8080
}
8181
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
82+
if (value_type == IS_VAR && ref) {
83+
ZEND_ASSERT(GC_REFCOUNT(ref) > 1);
84+
--GC_REFCOUNT(ref);
85+
}
8286
return variable_ptr;
8387
}
8488
garbage = Z_COUNTED_P(variable_ptr);

0 commit comments

Comments
 (0)