[php-src] Issue #21605: Missing addref for Countable::count()
| From: | iluuu1994 | Date: | Thu, 02 Apr 2026 13:40:57 +0000 |
| Subject: | [php-src] Issue #21605: Missing addref for Countable::count() | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251888@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/21605
Author: iluuu1994
### Description
### Description
The following code:
```php
<?php
class C implements Countable {
public function count(): int {
global $c;
$c = null;
var_dump($this);
return 42;
}
}
$c = new C;
var_dump(count($c));
```
Resulted in this output:
```
Segfault
```
But I expected this output instead:
```
```
Originally reported by @cnwangjihe.
### PHP Version
```plain
PHP 8.2+
```
### Operating System
_No response_