Skip to content

Commit b295827

Browse files
committed
fixup! http: support lazy-loading libcurl also on Windows
If the `.dll` file could not be loaded, let's print an error message. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent a2e49ec commit b295827

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

compat/lazyload-curl.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,22 @@ static void *load_library(const char *name)
5656
dll_path[len] = '/';
5757
memcpy(dll_path + len + 1, name, name_size);
5858

59-
if (!access(dll_path, R_OK))
60-
return (void *)LoadLibraryExA(dll_path, NULL, 0);
59+
if (!access(dll_path, R_OK)) {
60+
void *res = (void *)LoadLibraryExA(dll_path, NULL, 0);
61+
if (!res) {
62+
DWORD err = GetLastError();
63+
char buf[1024];
64+
65+
if (!FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
66+
FORMAT_MESSAGE_ARGUMENT_ARRAY |
67+
FORMAT_MESSAGE_IGNORE_INSERTS,
68+
NULL, err, LANG_NEUTRAL,
69+
buf, sizeof(buf) - 1, NULL))
70+
xsnprintf(buf, sizeof(buf), "last error: %ld", err);
71+
error("LoadLibraryExA() failed with: %s", buf);
72+
}
73+
return res;
74+
}
6175
}
6276

6377
path = *sep ? sep + 1 : NULL;

0 commit comments

Comments
 (0)