mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-04 22:15:33 +02:00
Don't crash if MiniFFI.initialize gets nil imports
This commit is contained in:
parent
ff4df0df56
commit
52a55ebd09
1 changed files with 6 additions and 2 deletions
|
@ -14,10 +14,13 @@
|
||||||
#define _T_POINTER 2
|
#define _T_POINTER 2
|
||||||
#define _T_INTEGER 3
|
#define _T_INTEGER 3
|
||||||
|
|
||||||
|
|
||||||
|
// Might need to let MiniFFI.initialize set calling convention
|
||||||
|
// as an optional arg, this won't work with everything
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
typedef void* (__stdcall *MINIFFI_FUNC)(...);
|
typedef void* (__stdcall *MINIFFI_FUNC)(...);
|
||||||
#else
|
#else
|
||||||
typedef void* (__cdecl *MINIFFI_FUNC)(...);
|
typedef void* (*MINIFFI_FUNC)(...);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MiniFFI class, also named Win32API on Windows
|
// MiniFFI class, also named Win32API on Windows
|
||||||
|
@ -59,12 +62,13 @@ MiniFFI_initialize(VALUE self, VALUE libname, VALUE func, VALUE imports, VALUE e
|
||||||
rb_iv_set(self, "_libname", libname);
|
rb_iv_set(self, "_libname", libname);
|
||||||
|
|
||||||
VALUE ary_imports = rb_ary_new();
|
VALUE ary_imports = rb_ary_new();
|
||||||
VALUE *entry = RARRAY_PTR(imports);
|
VALUE *entry;
|
||||||
switch (TYPE(imports))
|
switch (TYPE(imports))
|
||||||
{
|
{
|
||||||
case T_NIL:
|
case T_NIL:
|
||||||
break;
|
break;
|
||||||
case T_ARRAY:
|
case T_ARRAY:
|
||||||
|
entry = RARRAY_PTR(imports);
|
||||||
for (int i = 0; i < RARRAY_LEN(imports); i++)
|
for (int i = 0; i < RARRAY_LEN(imports); i++)
|
||||||
{
|
{
|
||||||
SafeStringValue(entry[i]);
|
SafeStringValue(entry[i]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue