Skip to content

Commit 0fbe38f

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 86ef9c0 commit 0fbe38f

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
@@ -1638,7 +1638,8 @@ static void ensure_socket_initialization(void)
16381638
WSAGetLastError());
16391639

16401640
for (name = libraries; *name; name++) {
1641-
ipv6_dll = LoadLibrary(*name);
1641+
ipv6_dll = LoadLibraryExA(*name, NULL,
1642+
LOAD_LIBRARY_SEARCH_SYSTEM32);
16421643
if (!ipv6_dll)
16431644
continue;
16441645

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)