Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2f819d1

Browse files
committedAug 28, 2023
fixup! http: support lazy-loading libcurl also on Windows
Allow `libcurl-4.dll` to be located in a path containing non-ASCII characters. This fixes #4573. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent b295827 commit 2f819d1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

‎compat/lazyload-curl.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ static void *load_library(const char *name)
5757
memcpy(dll_path + len + 1, name, name_size);
5858

5959
if (!access(dll_path, R_OK)) {
60-
void *res = (void *)LoadLibraryExA(dll_path, NULL, 0);
60+
wchar_t wpath[MAX_PATH];
61+
int wlen = MultiByteToWideChar(CP_UTF8, 0, dll_path, -1, wpath, ARRAY_SIZE(wpath));
62+
void *res = wlen ? (void *)LoadLibraryExW(wpath, NULL, 0) : NULL;
6163
if (!res) {
6264
DWORD err = GetLastError();
6365
char buf[1024];
@@ -68,7 +70,7 @@ static void *load_library(const char *name)
6870
NULL, err, LANG_NEUTRAL,
6971
buf, sizeof(buf) - 1, NULL))
7072
xsnprintf(buf, sizeof(buf), "last error: %ld", err);
71-
error("LoadLibraryExA() failed with: %s", buf);
73+
error("LoadLibraryExW() failed with: %s", buf);
7274
}
7375
return res;
7476
}

0 commit comments

Comments
 (0)
Please sign in to comment.