summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-06-26 17:49:46 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-06-26 17:49:46 -0700
commit7314d2c5e6945a941111292cf40a6cd6813b38c9 (patch)
tree847e763371bd9e905e5bfe20ff0f77e80a30769b
parentee501020c7bbced9edb812da3c9d5bcabff96a24 (diff)
downloadffi-7314d2c5e6945a941111292cf40a6cd6813b38c9.tar.gz
methodHandleParamTypes needs to refer to valid memory after rbffi_MethodHandle_Init
Fixes #440
-rw-r--r--ext/ffi_c/MethodHandle.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/ffi_c/MethodHandle.c b/ext/ffi_c/MethodHandle.c
index b60f9cc..cee1df5 100644
--- a/ext/ffi_c/MethodHandle.c
+++ b/ext/ffi_c/MethodHandle.c
@@ -132,6 +132,12 @@ rbffi_MethodHandle_CodeAddress(MethodHandle* handle)
#ifndef CUSTOM_TRAMPOLINE
static void attached_method_invoke(ffi_cif* cif, void* retval, METHOD_PARAMS parameters, void* user_data);
+static ffi_type* methodHandleParamTypes[] = {
+ &ffi_type_sint,
+ &ffi_type_pointer,
+ &ffi_type_ulong,
+};
+
static ffi_cif mh_cif;
static bool
@@ -333,12 +339,7 @@ void
rbffi_MethodHandle_Init(VALUE module)
{
#ifndef CUSTOM_TRAMPOLINE
- ffi_status ffiStatus;
- ffi_type* methodHandleParamTypes[] = {
- &ffi_type_sint,
- &ffi_type_pointer,
- &ffi_type_ulong,
- };
+ ffi_status ffiStatus;
#endif
defaultClosurePool = rbffi_ClosurePool_New((int) trampoline_size(), prep_trampoline, NULL);