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:
parent
6ae5ff26b0
commit
52cabca4e5
20
osdep/io.c
20
osdep/io.c
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user