-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path222362.mypatch
40 lines (35 loc) · 1.52 KB
/
222362.mypatch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From: Alex Henrie <[email protected]>
Subject: [PATCH] ws2_32: Fix memory leak on error path in get_local_ips (cppcheck)
Message-Id: <[email protected]>
Date: Sun, 19 Dec 2021 21:57:34 -0700
Signed-off-by: Alex Henrie <[email protected]>
---
dlls/ws2_32/protocol.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c
index 867e9513ca2..56b7379cccc 100644
--- a/dlls/ws2_32/protocol.c
+++ b/dlls/ws2_32/protocol.c
@@ -806,7 +806,7 @@ static struct hostent *get_local_ips( char *hostname )
IP_ADAPTER_INFO *adapters = NULL, *k;
struct hostent *hostlist = NULL;
MIB_IPFORWARDTABLE *routes = NULL;
- struct route *route_addrs = NULL;
+ struct route *route_addrs = NULL, *new_route_addrs;
DWORD adap_size, route_size, n;
/* Obtain the size of the adapter list and routing table, also allocate memory */
@@ -852,9 +852,10 @@ static struct hostent *get_local_ips( char *hostname )
}
if (exists)
continue;
- route_addrs = realloc( route_addrs, (numroutes + 1) * sizeof(struct route) );
- if (!route_addrs)
+ new_route_addrs = realloc( route_addrs, (numroutes + 1) * sizeof(struct route) );
+ if (!new_route_addrs)
goto cleanup;
+ route_addrs = new_route_addrs;
route_addrs[numroutes].interface = ifindex;
route_addrs[numroutes].metric = ifmetric;
route_addrs[numroutes].default_route = ifdefault;
--
2.34.1