|
30 | 30 | #include "main/SAPI.h"
|
31 | 31 | #include "TSRM.h"
|
32 | 32 | #include "zend_fibers.h"
|
| 33 | +#include "zend_call_stack.h" |
33 | 34 |
|
34 | 35 | #include <sys/types.h>
|
35 | 36 | #include <sys/stat.h>
|
@@ -932,9 +933,10 @@ static void zend_ffi_callback_hash_dtor(zval *zv) /* {{{ */
|
932 | 933 | if (callback_data->fcc.function_handler->common.fn_flags & ZEND_ACC_CLOSURE) {
|
933 | 934 | OBJ_RELEASE(ZEND_CLOSURE_OBJECT(callback_data->fcc.function_handler));
|
934 | 935 | }
|
| 936 | + ffi_type **arg_types = callback_data->arg_types; |
935 | 937 | for (int i = 0; i < callback_data->arg_count; ++i) {
|
936 |
| - if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { |
937 |
| - efree(callback_data->arg_types[i]); |
| 938 | + if (arg_types[i]->type == FFI_TYPE_STRUCT) { |
| 939 | + efree(arg_types[i]); |
938 | 940 | }
|
939 | 941 | }
|
940 | 942 | if (callback_data->ret_type->type == FFI_TYPE_STRUCT) {
|
@@ -1076,7 +1078,7 @@ static void zend_ffi_callback_trampoline(ffi_cif* cif, void* ret, void** args, v
|
1076 | 1078 |
|
1077 | 1079 | if (zend_atomic_bool_load_ex(&FFI_G(callback_in_progress))) {
|
1078 | 1080 | // call PHP function
|
1079 |
| - zend_fiber_transfer transfer = zend_fiber_resume(&call_data.data->fiber, NULL, false); |
| 1081 | + zend_fiber_resume(&call_data.data->fiber, NULL, false); |
1080 | 1082 | zend_ffi_type *ret_type = ZEND_FFI_TYPE(call_data.data->type->func.ret_type);
|
1081 | 1083 | if(ret_type->kind != ZEND_FFI_TYPE_VOID){
|
1082 | 1084 | // extract return value from fiber
|
@@ -1139,15 +1141,16 @@ static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value) /* {{{ *
|
1139 | 1141 | if (type->func.args) {
|
1140 | 1142 | int n = 0;
|
1141 | 1143 | zend_ffi_type *arg_type;
|
| 1144 | + ffi_type **arg_types = callback_data->arg_types; |
1142 | 1145 |
|
1143 | 1146 | ZEND_HASH_PACKED_FOREACH_PTR(type->func.args, arg_type) {
|
1144 | 1147 | arg_type = ZEND_FFI_TYPE(arg_type);
|
1145 |
| - callback_data->arg_types[n] = zend_ffi_get_type(arg_type); |
1146 |
| - if (!callback_data->arg_types[n]) { |
| 1148 | + arg_types[n] = zend_ffi_get_type(arg_type); |
| 1149 | + if (!arg_types[n]) { |
1147 | 1150 | zend_ffi_pass_unsupported(arg_type);
|
1148 | 1151 | for (int i = 0; i < n; ++i) {
|
1149 |
| - if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { |
1150 |
| - efree(callback_data->arg_types[i]); |
| 1152 | + if (arg_types[i]->type == FFI_TYPE_STRUCT) { |
| 1153 | + efree(arg_types[i]); |
1151 | 1154 | }
|
1152 | 1155 | }
|
1153 | 1156 | efree(callback_data);
|
@@ -1178,9 +1181,10 @@ static void *zend_ffi_create_callback(zend_ffi_type *type, zval *value) /* {{{ *
|
1178 | 1181 | if (ffi_prep_closure_loc(callback, &callback_data->cif, zend_ffi_callback_trampoline, callback_data, code) != FFI_OK) {
|
1179 | 1182 | zend_throw_error(zend_ffi_exception_ce, "Cannot prepare callback");
|
1180 | 1183 | free_on_failure: ;
|
| 1184 | + ffi_type **arg_types = callback_data->arg_types; |
1181 | 1185 | for (int i = 0; i < callback_data->arg_count; ++i) {
|
1182 |
| - if (callback_data->arg_types[i]->type == FFI_TYPE_STRUCT) { |
1183 |
| - efree(callback_data->arg_types[i]); |
| 1186 | + if (arg_types[i]->type == FFI_TYPE_STRUCT) { |
| 1187 | + efree(arg_types); |
1184 | 1188 | }
|
1185 | 1189 | }
|
1186 | 1190 | if (callback_data->ret_type->type == FFI_TYPE_STRUCT) {
|
|
0 commit comments