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
If the `.dll` file could not be loaded, let's print an error message.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Aug 28, 2023
1 parent a2e49ec commit b295827
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions compat/lazyload-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,22 @@ 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)) {
void *res = (void *)LoadLibraryExA(dll_path, NULL, 0);
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("LoadLibraryExA() failed with: %s", buf);
}
return res;
}
}

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

0 comments on commit b295827

Please sign in to comment.