diff options
author | Kacper Michajłow <kasper93@gmail.com> | 2024-01-21 18:27:04 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2024-01-22 14:41:46 +0000 |
commit | 52cabca4e549e1e8304f6caf8022d2435b9185d3 (patch) | |
tree | 18bafe858572b39e10d743de09f797ff9593eab1 /osdep | |
parent | 6ae5ff26b0812052c2c6586edd0e88e42bd96bb3 (diff) | |
download | mpv-52cabca4e549e1e8304f6caf8022d2435b9185d3.tar.bz2 mpv-52cabca4e549e1e8304f6caf8022d2435b9185d3.tar.xz |
osdep/io: expand path before LoadLibrary
Fixes compatibility with loading scripts from relative config paths.
Fixes #13212
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/io.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/osdep/io.c b/osdep/io.c index bba9ddc1dd..93f97b5ecf 100644 --- a/osdep/io.c +++ b/osdep/io.c @@ -738,9 +738,23 @@ static void mp_dl_init(void) void *mp_dlopen(const char *filename, int flag) { - wchar_t *wfilename = mp_from_utf8(NULL, filename); - HMODULE lib = LoadLibraryW(wfilename); - talloc_free(wfilename); + HMODULE lib = NULL; + void *ta_ctx = talloc_new(NULL); + wchar_t *wfilename = mp_from_utf8(ta_ctx, filename); + + DWORD len = GetFullPathNameW(wfilename, 0, NULL, NULL); + if (!len) + goto err; + + wchar_t *path = talloc_array(ta_ctx, wchar_t, len); + len = GetFullPathNameW(wfilename, len, path, NULL); + if (!len) + goto err; + + lib = LoadLibraryW(path); + +err: + talloc_free(ta_ctx); mp_dl_result.errcode = GetLastError(); return (void *)lib; } |