]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Workaround for platform dlerror() returning NULL.
authorMike Pall <mike>
Sun, 8 Dec 2019 18:25:45 +0000 (19:25 +0100)
committerMike Pall <mike>
Sun, 8 Dec 2019 18:25:45 +0000 (19:25 +0100)
Contributed by mcclure.

src/lj_clib.c

index 8dc3c10e3bf18ac6add69dfa3bd4a09dac90c44c..dc72dcedb228884425e7801db74eaf8c7c19848f 100644 (file)
@@ -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;