Alex Henrie : nsiproxy: Fix memory leaks on error paths in get_ipv6_addr_scope_table (cppcheck).
Alexandre Julliard
julliard at winehq.org
Mon Dec 20 15:42:39 CST 2021
Module: wine
Branch: master
Commit: cf7dd52091400c39c3f5718de8258b3ca97f36be
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cf7dd52091400c39c3f5718de8258b3ca97f36be
Author: Alex Henrie <alexhenrie24 at gmail.com>
Date: Sun Dec 19 21:55:31 2021 -0700
nsiproxy: Fix memory leaks on error paths in get_ipv6_addr_scope_table (cppcheck).
Signed-off-by: Alex Henrie <alexhenrie24 at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/nsiproxy.sys/tcp.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dlls/nsiproxy.sys/tcp.c b/dlls/nsiproxy.sys/tcp.c
index 6dd0aaa9b45..0cd81ae86e5 100644
--- a/dlls/nsiproxy.sys/tcp.c
+++ b/dlls/nsiproxy.sys/tcp.c
@@ -235,7 +235,7 @@ static inline MIB_TCP_STATE tcp_state_to_mib_state( int state )
struct ipv6_addr_scope *get_ipv6_addr_scope_table( unsigned int *size )
{
- struct ipv6_addr_scope *table = NULL;
+ struct ipv6_addr_scope *table = NULL, *new_table;
unsigned int table_size = 0, num = 0;
#ifdef __linux__
@@ -260,11 +260,12 @@ struct ipv6_addr_scope *get_ipv6_addr_scope_table( unsigned int *size )
{
if (!table_size) table_size = 4;
else table_size *= 2;
- if (!(table = realloc( table, table_size * sizeof(table[0]) )))
+ if (!(new_table = realloc( table, table_size * sizeof(table[0]) )))
{
fclose( fp );
goto failed;
}
+ table = new_table;
}
entry = table + num - 1;
@@ -292,11 +293,12 @@ struct ipv6_addr_scope *get_ipv6_addr_scope_table( unsigned int *size )
{
if (!table_size) table_size = 4;
else table_size *= 2;
- if (!(table = realloc( table, table_size * sizeof(table[0]) )))
+ if (!(new_table = realloc( table, table_size * sizeof(table[0]) )))
{
freeifaddrs( addrs );
goto failed;
}
+ table = new_table;
}
sin6 = (struct sockaddr_in6 *)cur->ifa_addr;
More information about the wine-cvs
mailing list