Skip to content

Commit 22e6b5e

Browse files
committed
Merge branch 'PHP-7.1'
2 parents ec31924 + 280e8da commit 22e6b5e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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
@@ -81,6 +81,10 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
8181
return variable_ptr;
8282
}
8383
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
84+
if (value_type == IS_VAR && ref) {
85+
ZEND_ASSERT(GC_REFCOUNT(ref) > 1);
86+
--GC_REFCOUNT(ref);
87+
}
8488
return variable_ptr;
8589
}
8690
garbage = Z_COUNTED_P(variable_ptr);

0 commit comments

Comments
 (0)