php-src/Zend/tests/bug65051.phpt
Nikita Popov 86434be946 Fix bug #65051: count() off by one inside unset()
nNumOfElements was incremented after the pDestructor code, so any
code in the dtor would get a wrong number of elements.

Right now the bucket deletion code is replicated in four places,
it should probably be moved off into one function (or rather,
zend_hash_apply_deleter should be used everywhere). The codes are
subtly different though in that the HANDLE_UNBLOCK_INTERRUPTIONS()
happens in different places. In particular it seems odd that in
some cases interruptions stay blocked during the destructor call.
2013-06-17 23:44:13 +02:00

24 lines
333 B
PHP

--TEST--
Bug #65051: count() off by one inside unset()
--FILE--
<?php
class Foo {
public $array;
public function __destruct() {
var_dump(count($this->array[0]));
var_dump($this->array[0]);
}
}
$array = [[new Foo]];
$array[0][0]->array =& $array;
unset($array[0][0]);
?>
--EXPECT--
int(0)
array(0) {
}