Skip to content

Commit

Permalink
Fix WeakReference uniquing is TAG_HT is used
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Nov 3, 2021
1 parent c5da497 commit 546e558
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Zend/tests/weakrefs/weakmap_multiple_weakrefs.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ $map2 = new WeakMap;
$map2[$obj] = 1;
$map3 = clone $map2;

var_dump($ref === WeakReference::create($obj));
var_dump($ref->get(), $map, $map2, $map3);
unset($obj);
var_dump($ref->get(), $map, $map2, $map3);
Expand All @@ -31,6 +32,7 @@ unset($obj);

?>
--EXPECT--
bool(true)
object(stdClass)#1 (0) {
}
object(WeakMap)#3 (1) {
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static zend_always_inline zend_bool zend_weakref_find(zval *referent, zval *retu
}

if (tag == ZEND_WEAKREF_TAG_HT) {
ZEND_HASH_FOREACH(ptr, tagged_ptr) {
ZEND_HASH_FOREACH_PTR(ptr, tagged_ptr) {
if (ZEND_WEAKREF_GET_TAG(tagged_ptr) == ZEND_WEAKREF_TAG_REF) {
ptr = ZEND_WEAKREF_GET_PTR(tagged_ptr);
goto found_weakref;
Expand Down

0 comments on commit 546e558

Please sign in to comment.