mirror of
https://github.com/php/php-src.git
synced 2024-11-27 11:53:33 +08:00
25 lines
426 B
PHP
25 lines
426 B
PHP
--TEST--
|
|
GH-8433 (Assigning function pointers to structs in FFI leaks memory)
|
|
--EXTENSIONS--
|
|
ffi
|
|
--INI--
|
|
ffi.enable=1
|
|
--FILE--
|
|
<?php
|
|
|
|
$ffi = FFI::cdef("typedef struct { int a; } bar;");
|
|
$x = $ffi->new("bar(*)(void)");
|
|
FFI::addr($x)[0] = function() use ($ffi) {
|
|
$bar = $ffi->new("bar");
|
|
$bar->a = 2;
|
|
return $bar;
|
|
};
|
|
var_dump($x());
|
|
|
|
?>
|
|
--EXPECTF--
|
|
object(FFI\CData:struct <anonymous>)#%d (1) {
|
|
["a"]=>
|
|
int(2)
|
|
}
|