Skip to content

Commit c6f050a

Browse files
dschogitster
authored andcommitted
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]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c4df23f commit c6f050a

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
@@ -1577,7 +1577,8 @@ static void ensure_socket_initialization(void)
15771577
WSAGetLastError());
15781578

15791579
for (name = libraries; *name; name++) {
1580-
ipv6_dll = LoadLibrary(*name);
1580+
ipv6_dll = LoadLibraryExA(*name, NULL,
1581+
LOAD_LIBRARY_SEARCH_SYSTEM32);
15811582
if (!ipv6_dll)
15821583
continue;
15831584

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)