瀏覽代碼

FFI: Workaround for platform dlerror() returning NULL.

Contributed by mcclure.
Mike Pall 5 年之前
父節點
當前提交
478bcfe52a
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      src/lj_clib.c

+ 2 - 1
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;