From: Mike Pall Date: Sun, 8 Dec 2019 18:25:45 +0000 (+0100) Subject: FFI: Workaround for platform dlerror() returning NULL. X-Git-Tag: v2.1.ROLLING~291^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=478bcfe52a653bf338f17690147fa9f5793f5b42;p=thirdparty%2FLuaJIT.git FFI: Workaround for platform dlerror() returning NULL. Contributed by mcclure. --- diff --git a/src/lj_clib.c b/src/lj_clib.c index 8dc3c10e..dc72dced 100644 --- a/src/lj_clib.c +++ b/src/lj_clib.c @@ -118,12 +118,13 @@ static void *clib_loadlib(lua_State *L, const char *name, int global) RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); if (!h) { const char *e, *err = dlerror(); - if (*err == '/' && (e = strchr(err, ':')) && + if (err && *err == '/' && (e = strchr(err, ':')) && (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); if (h) return h; err = dlerror(); } + if (!err) err = "dlopen failed"; lj_err_callermsg(L, err); } return h;