Skip to content

Commit 6f745cc

Browse files
committed
mingw: load system libraries the recommended way
When we access IPv6-related functions, we load the corresponding system library using the `LoadLibrary()` function, which is not the recommended way to load system libraries. In practice, it does not make a difference: the `ws2_32.dll` library containing the IPv6 functions is already loaded into memory, so LoadLibrary() simply reuses the already-loaded library. Still, recommended way is recommended way, so let's use that instead. While at it, also adjust the code in contrib/ that loads system libraries. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e2986e3 commit 6f745cc

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

compat/mingw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,8 @@ static void ensure_socket_initialization(void)
16861686
WSAGetLastError());
16871687

16881688
for (name = libraries; *name; name++) {
1689-
ipv6_dll = LoadLibrary(*name);
1689+
ipv6_dll = LoadLibraryExA(*name, NULL,
1690+
LOAD_LIBRARY_SEARCH_SYSTEM32);
16901691
if (!ipv6_dll)
16911692
continue;
16921693

contrib/credential/wincred/git-credential-wincred.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ static CredDeleteWT CredDeleteW;
7575
static void load_cred_funcs(void)
7676
{
7777
/* load DLLs */
78-
advapi = LoadLibrary("advapi32.dll");
78+
advapi = LoadLibraryExA("advapi32.dll", NULL,
79+
LOAD_LIBRARY_SEARCH_SYSTEM32);
7980
if (!advapi)
8081
die("failed to load advapi32.dll");
8182

0 commit comments

Comments
 (0)