From 9b91b9548e151d2cac79b1fd2a613e22dfd9d62f Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Mon, 23 Sep 2024 12:30:07 +0200 Subject: [PATCH] dlopen: fix `dl.open` on absolute path (#511) --- assets/dl.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/assets/dl.lua b/assets/dl.lua index 87dd01cfd..f60dd77a8 100644 --- a/assets/dl.lua +++ b/assets/dl.lua @@ -91,14 +91,20 @@ function dl.dlopen(library, load_func, depth) local padding = depth * 4 for pspec in string.gmatch( - library:sub(1, 1) == "/" and "" or dl.library_path, + library:sub(1, 1) == "/" and "/" or dl.library_path, "([^;:]+)") do - local lname, matches = string.gsub(pspec, "%?", library) - if matches == 0 then - -- if pathspec does not contain a '?', - -- we append the library name to the pathspec - lname = lname .. '/' .. library + local lname + if library:sub(1, 1) == "/" and pspec == "/" then + lname = library + else + local matches + lname, matches = string.gsub(pspec, "%?", library) + if matches == 0 then + -- if pathspec does not contain a '?', + -- we append the library name to the pathspec + lname = lname .. '/' .. library + end end local ok, lib = pcall(Elf.open, lname)