Closed
Description
Description
The following code:
<?php
$ffi = FFI::cdef("typedef struct { int a; } bar;");
$x = $ffi->new("bar(*)(void)");
FFI::addr($x)[0] = fn() => $ffi->new("bar");
var_dump($x());
Resulted in these memory leaks:
object(FFI\CData:struct <anonymous>)#5 (1) {
["a"]=>
int(0)
}
[Sun Apr 24 03:13:26 2022] Script: 'Standard input code'
/Users/bob/php-src/ext/ffi/ffi.c(244) : Freeing 0x000000010c857400 (88 bytes), script=Standard input code
[Sun Apr 24 03:13:26 2022] Script: 'Standard input code'
/Users/bob/php-src/ext/ffi/ffi.c(365) : Freeing 0x000000010c85daf0 (40 bytes), script=Standard input code
=== Total 2 memory leaks detected ===
The first memory leak comes from calling (each call leaks memory - there seems to be a missing zval_ptr_dtor(&retval);
in zend_ffi_callback_trampoline
).
The second leak comes from the fake struct type not being freed.
PHP Version
master
Operating System
No response