Don't crash if MiniFFI.initialize gets nil imports

This commit is contained in:
Inori 2019-08-04 15:24:42 -04:00
parent ff4df0df56
commit 52a55ebd09

View file

@ -14,10 +14,13 @@
#define _T_POINTER 2
#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__
typedef void* (__stdcall *MINIFFI_FUNC)(...);
#else
typedef void* (__cdecl *MINIFFI_FUNC)(...);
typedef void* (*MINIFFI_FUNC)(...);
#endif
// 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);
VALUE ary_imports = rb_ary_new();
VALUE *entry = RARRAY_PTR(imports);
VALUE *entry;
switch (TYPE(imports))
{
case T_NIL:
break;
case T_ARRAY:
entry = RARRAY_PTR(imports);
for (int i = 0; i < RARRAY_LEN(imports); i++)
{
SafeStringValue(entry[i]);