diff options
author | Mike Pall <mike> | 2019-12-08 19:25:45 +0100 |
---|---|---|
committer | Mike Pall <mike> | 2019-12-08 19:25:45 +0100 |
commit | 478bcfe52a653bf338f17690147fa9f5793f5b42 (patch) | |
tree | f0841794ec1a67f9fbbad69d3c7b0c033787b269 | |
parent | 44382e833a9334c19e47e64e8078a322026e094d (diff) | |
download | luajit-478bcfe52a653bf338f17690147fa9f5793f5b42.tar.gz luajit-478bcfe52a653bf338f17690147fa9f5793f5b42.tar.bz2 luajit-478bcfe52a653bf338f17690147fa9f5793f5b42.zip |
FFI: Workaround for platform dlerror() returning NULL.
Contributed by mcclure.
-rw-r--r-- | src/lj_clib.c | 3 |
1 files changed, 2 insertions, 1 deletions
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) | |||
118 | RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); | 118 | RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); |
119 | if (!h) { | 119 | if (!h) { |
120 | const char *e, *err = dlerror(); | 120 | const char *e, *err = dlerror(); |
121 | if (*err == '/' && (e = strchr(err, ':')) && | 121 | if (err && *err == '/' && (e = strchr(err, ':')) && |
122 | (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { | 122 | (name = clib_resolve_lds(L, strdata(lj_str_new(L, err, e-err))))) { |
123 | h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); | 123 | h = dlopen(name, RTLD_LAZY | (global?RTLD_GLOBAL:RTLD_LOCAL)); |
124 | if (h) return h; | 124 | if (h) return h; |
125 | err = dlerror(); | 125 | err = dlerror(); |
126 | } | 126 | } |
127 | if (!err) err = "dlopen failed"; | ||
127 | lj_err_callermsg(L, err); | 128 | lj_err_callermsg(L, err); |
128 | } | 129 | } |
129 | return h; | 130 | return h; |