Skip to content

Commit 4f31a95

Browse files
committed
winsock: Fix a potential memleak in GetAdaptersInfo calls.
Thanks to Jean-Baptiste Noblot, who submitted the original patch to our Bugzilla in January 2015. Sorry for the delay! :) Fixes #27.
1 parent 6d9b64c commit 4f31a95

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/SDLnet.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,12 @@ int SDLNet_GetLocalAddresses(IPaddress *addresses, int maxcount)
270270
}
271271

272272
if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == ERROR_BUFFER_OVERFLOW) {
273-
pAdapterInfo = (IP_ADAPTER_INFO *) SDL_realloc(pAdapterInfo, ulOutBufLen);
274-
if (pAdapterInfo == NULL) {
273+
PIP_ADAPTER_INFO pAdapterInfoTmp = (PIP_ADAPTER_INFO) SDL_realloc(pAdapterInfo, ulOutBufLen);
274+
if (pAdapterInfoTmp == NULL) {
275+
SDL_free(pAdapterInfo);
275276
return 0;
276277
}
278+
pAdapterInfo = pAdapterInfoTmp;
277279
dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen);
278280
}
279281

0 commit comments

Comments
 (0)