Skip to content

Commit 55c2dbb

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix missing addref for Countable::count()
2 parents 4f40c20 + 8972938 commit 55c2dbb

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ PHP NEWS
1010
. Fixed bug GH-21504 (Incorrect RC-handling for ZEND_EXT_STMT op1). (ilutov)
1111
. Fixed bug GH-21478 (Forward property operations to real instance for
1212
initialized lazy proxies). (iliaal)
13+
. Fixed bug GH-21605 (Missing addref for Countable::count()). (ilutov)
1314

1415
- Curl:
1516
. Add support for brotli and zstd on Windows. (Shivam Mathur)

Zend/tests/gh21605.phpt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-21605: Missing addref for Countable::count()
3+
--CREDITS--
4+
cnwangjihe
5+
--FILE--
6+
<?php
7+
8+
class C implements Countable {
9+
public function count(): int {
10+
global $c;
11+
$c = null;
12+
var_dump($this);
13+
return 42;
14+
}
15+
}
16+
17+
$c = new C;
18+
var_dump(count($c));
19+
20+
?>
21+
--EXPECTF--
22+
object(C)#%d (0) {
23+
}
24+
int(42)

Zend/zend_vm_def.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9506,7 +9506,9 @@ ZEND_VM_COLD_CONST_HANDLER(190, ZEND_COUNT, CONST|TMPVAR|CV, UNUSED)
95069506
zval retval;
95079507

95089508
zend_function *count_fn = zend_hash_find_ptr(&zobj->ce->function_table, ZSTR_KNOWN(ZEND_STR_COUNT));
9509+
GC_ADDREF(zobj);
95099510
zend_call_known_instance_method_with_0_params(count_fn, zobj, &retval);
9511+
OBJ_RELEASE(zobj);
95109512
count = zval_get_long(&retval);
95119513
zval_ptr_dtor(&retval);
95129514
break;

Zend/zend_vm_execute.h

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)