Skip to content

Commit ddfa743

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix leak when creating cycle in hook
2 parents c7f0ac1 + fe504d3 commit ddfa743

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

Zend/tests/gh18907.phpt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--TEST--
2+
GH-18907: Leak when creating cycle inside hook
3+
--FILE--
4+
<?php
5+
6+
class Foo {
7+
public $prop {
8+
get {
9+
$this->prop = $this;
10+
return 1;
11+
}
12+
}
13+
}
14+
15+
function test() {
16+
var_dump((new Foo)->prop);
17+
}
18+
19+
/* Call twice to test the ZEND_IS_PROPERTY_HOOK_SIMPLE_GET() path. */
20+
test();
21+
test();
22+
23+
?>
24+
--EXPECT--
25+
int(1)
26+
int(1)

Zend/zend_object_handlers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ static bool zend_call_get_hook(
722722
return false;
723723
}
724724

725+
GC_ADDREF(zobj);
725726
zend_call_known_instance_method_with_0_params(get, zobj, rv);
727+
OBJ_RELEASE(zobj);
726728

727729
return true;
728730
}

0 commit comments

Comments
 (0)