Make C functions returning "void" to return PHP "null"

In PHP-2.0 and below we by mistake returned "obcect(FFI\CData:void)#2 (0) {}".
We decided not to fix this in PHP-2.0 and below to aboid BC breaks.
This commit is contained in:
Dmitry Stogov 2023-02-13 22:42:39 +03:00
parent 2abb5850ba
commit 851e4623f5
2 changed files with 6 additions and 3 deletions

View File

@ -2832,7 +2832,11 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
free_alloca(arg_values, arg_values_use_heap);
}
zend_ffi_cdata_to_zval(NULL, ret, ZEND_FFI_TYPE(type->func.ret_type), BP_VAR_R, return_value, 0, 1, 0);
if (ZEND_FFI_TYPE(type->func.ret_type)->kind != ZEND_FFI_TYPE_VOID) {
zend_ffi_cdata_to_zval(NULL, ret, ZEND_FFI_TYPE(type->func.ret_type), BP_VAR_R, return_value, 0, 1, 0);
} else {
ZVAL_NULL(return_value);
}
free_alloca(ret, ret_use_heap);
exit:

View File

@ -20,6 +20,5 @@ var_dump($libc->strlen("abc"));
?>
DONE
--EXPECT--
object(FFI\CData:void)#2 (0) {
}
NULL
DONE