Skip to content

Commit 478bcfe

Browse files
author
Mike Pall
committed
FFI: Workaround for platform dlerror() returning NULL.
Contributed by mcclure.
1 parent 44382e8 commit 478bcfe

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/lj_clib.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,13 @@ static void *clib_loadlib(lua_State *L, const char *name, int global)
118118
RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL));
119119
if (!h) {
120120
const char *e, *err = dlerror();
121-
if (*err == '/' && (e = strchr(err, ':')) &&
121+
if (err && *err == '/' && (e = strchr(err, ':')) &&
122122
(name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) {
123123
h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL));
124124
if (h) return h;
125125
err = dlerror();
126126
}
127+
if (!err) err = "dlopen failed";
127128
lj_err_callermsg(L, err);
128129
}
129130
return h;

0 commit comments

Comments
 (0)