@@ -2585,10 +2585,11 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
25852585 ffi_type * * arg_types = NULL ;
25862586 void * * arg_values = NULL ;
25872587 uint32_t n , arg_count ;
2588- ffi_arg ret ;
2588+ void * ret ;
25892589 zend_ffi_type * arg_type ;
25902590 ALLOCA_FLAG (arg_types_use_heap = 0 )
25912591 ALLOCA_FLAG (arg_values_use_heap = 0 )
2592+ ALLOCA_FLAG (ret_use_heap = 0 )
25922593
25932594 ZEND_ASSERT (type -> kind == ZEND_FFI_TYPE_FUNC );
25942595 arg_count = type -> func .args ? zend_hash_num_elements (type -> func .args ) : 0 ;
@@ -2676,7 +2677,8 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
26762677 }
26772678 }
26782679
2679- ffi_call (& cif , addr , & ret , arg_values );
2680+ ret = do_alloca (MAX (ret_type -> size , sizeof (ffi_arg )), ret_use_heap );
2681+ ffi_call (& cif , addr , ret , arg_values );
26802682
26812683 for (n = 0 ; n < arg_count ; n ++ ) {
26822684 if (arg_types [n ]-> type == FFI_TYPE_STRUCT ) {
@@ -2692,7 +2694,8 @@ static ZEND_FUNCTION(ffi_trampoline) /* {{{ */
26922694 free_alloca (arg_values , arg_values_use_heap );
26932695 }
26942696
2695- zend_ffi_cdata_to_zval (NULL , (void * )& ret , ZEND_FFI_TYPE (type -> func .ret_type ), BP_VAR_R , return_value , 0 , 1 );
2697+ zend_ffi_cdata_to_zval (NULL , ret , ZEND_FFI_TYPE (type -> func .ret_type ), BP_VAR_R , return_value , 0 , 1 );
2698+ free_alloca (ret , ret_use_heap );
26962699
26972700exit :
26982701 zend_string_release (EX (func )-> common .function_name );
0 commit comments