Skip to content

Commit

Permalink
fixup! http: support lazy-loading libcurl also on Windows
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dscho committed Aug 28, 2023
1 parent b295827 commit 2f819d1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions compat/lazyload-curl.c
Expand Up @@ -57,7 +57,9 @@ static void *load_library(const char *name)
memcpy(dll_path + len + 1, name, name_size);

if (!access(dll_path, R_OK)) {
void *res = (void *)LoadLibraryExA(dll_path, NULL, 0);
wchar_t wpath[MAX_PATH];
int wlen = MultiByteToWideChar(CP_UTF8, 0, dll_path, -1, wpath, ARRAY_SIZE(wpath));
void *res = wlen ? (void *)LoadLibraryExW(wpath, NULL, 0) : NULL;
if (!res) {
DWORD err = GetLastError();
char buf[1024];
Expand All @@ -68,7 +70,7 @@ static void *load_library(const char *name)
NULL, err, LANG_NEUTRAL,
buf, sizeof(buf) - 1, NULL))
xsnprintf(buf, sizeof(buf), "last error: %ld", err);
error("LoadLibraryExA() failed with: %s", buf);
error("LoadLibraryExW() failed with: %s", buf);
}
return res;
}
Expand Down

0 comments on commit 2f819d1

Please sign in to comment.