Skip to content

Commit

Permalink
dlopen: fix dl.open on absolute path (koreader#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit-pierre authored Sep 23, 2024
1 parent e8229d5 commit 9b91b95
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions assets/dl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 9b91b95

Please sign in to comment.