1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-16 12:17:12 +00:00

osdep/io: expand path before LoadLibrary

Fixes compatibility with loading scripts from relative config paths.

Fixes #13212
This commit is contained in:
Kacper Michajłow 2024-01-21 18:27:04 +01:00 committed by Dudemanguy
parent 6ae5ff26b0
commit 52cabca4e5

View File

@ -738,9 +738,23 @@ static void mp_dl_init(void)
void *mp_dlopen(const char *filename, int flag) void *mp_dlopen(const char *filename, int flag)
{ {
wchar_t *wfilename = mp_from_utf8(NULL, filename); HMODULE lib = NULL;
HMODULE lib = LoadLibraryW(wfilename); void *ta_ctx = talloc_new(NULL);
talloc_free(wfilename); 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(); mp_dl_result.errcode = GetLastError();
return (void *)lib; return (void *)lib;
} }