Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Zend/tests/weakrefs/gh20073.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
GH-20073 (Assertion failure in WeakMap offset operations on reference)
--FILE--
<?php
$obj = new stdClass;
$map = new WeakMap;
$integer = 1;
$map[$obj] = 0;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is necessary as a ref-assign uses read_dimension, and that won't work if the object is not yet in the map. Perhaps we should make this relaxed for BP_VAR_RW such that a direct reference assign is possible, but that's likely master-only-material.

$map[$obj] =& $integer;
$integer++;
var_dump($map[$obj], $map->offsetGet($obj));
?>
--EXPECT--
int(2)
int(2)
2 changes: 1 addition & 1 deletion Zend/zend_weakrefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ ZEND_METHOD(WeakMap, offsetGet)
return;
}

ZVAL_COPY(return_value, zv);
RETURN_COPY_DEREF(zv);
}

ZEND_METHOD(WeakMap, offsetSet)
Expand Down
Loading