Skip to content

Commit ff5fa0d

Browse files
committed
Fixed support for callbacks with "void" return type
1 parent d4d0e2e commit ff5fa0d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/ffi/ffi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,7 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
750750
{
751751
zend_ffi_callback_data *callback_data = (zend_ffi_callback_data*)data;
752752
zend_fcall_info fci;
753+
zend_ffi_type *ret_type;
753754
zval retval;
754755
ALLOCA_FLAG(use_heap)
755756

@@ -787,7 +788,10 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
787788
}
788789
free_alloca(fci.params, use_heap);
789790

790-
zend_ffi_zval_to_cdata(ret, ZEND_FFI_TYPE(callback_data->type->func.ret_type), &retval);
791+
ret_type = ZEND_FFI_TYPE(callback_data->type->func.ret_type);
792+
if (ret_type->kind != ZEND_FFI_TYPE_VOID) {
793+
zend_ffi_zval_to_cdata(ret, ret_type, &retval);
794+
}
791795
}
792796
/* }}} */
793797

0 commit comments

Comments
 (0)