Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load libcurl-4.dll correctly even when there are umlauts in its absolute path #4575

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions compat/lazyload-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,24 @@ static void *load_library(const char *name)
dll_path[len] = '/';
memcpy(dll_path + len + 1, name, name_size);

if (!access(dll_path, R_OK))
return (void *)LoadLibraryExA(dll_path, NULL, 0);
if (!access(dll_path, R_OK)) {
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];

if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ARGUMENT_ARRAY |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err, LANG_NEUTRAL,
buf, sizeof(buf) - 1, NULL))
xsnprintf(buf, sizeof(buf), "last error: %ld", err);
error("LoadLibraryExW() failed with: %s", buf);
}
return res;
}
}

path = *sep ? sep + 1 : NULL;
Expand Down
Loading