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
26 changes: 26 additions & 0 deletions Zend/tests/gh18907.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
GH-18907: Leak when creating cycle inside hook
--FILE--
<?php

class Foo {
public $prop {
get {
$this->prop = $this;
return 1;
}
}
}

function test() {
var_dump((new Foo)->prop);
}

/* Call twice to test the ZEND_IS_PROPERTY_HOOK_SIMPLE_GET() path. */
test();
test();

?>
--EXPECT--
int(1)
int(1)
2 changes: 2 additions & 0 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,9 @@ static bool zend_call_get_hook(
return false;
}

GC_ADDREF(zobj);
zend_call_known_instance_method_with_0_params(get, zobj, rv);
OBJ_RELEASE(zobj);

return true;
}
Expand Down