diff mbox series

[16/17] wispr: Avoid double-free in 'free_wispr_routes'.

Message ID 20231116010259.628527-17-gerickson@nuovations.com (mailing list archive)
State Superseded
Headers show
Series Address Redundant IPv4 Reachability Checks | expand

Commit Message

Grant Erickson Nov. 16, 2023, 1:02 a.m. UTC
Now that 'free_wispr_routes' can be invoked in terminal free-only
as well as cancel-latently-followed-by-free contexts, ensure that
a double-free is avoided with both the 'route->address' and
'wp_context->route_list->data' by explicitly nulling them after
calling 'g_free' on them.
---
 src/wispr.c | 3 +++
 1 file changed, 3 insertions(+)
diff mbox series

Patch

diff --git a/src/wispr.c b/src/wispr.c
index 8b555cfd5d6f..4a52b03c2ee7 100644
--- a/src/wispr.c
+++ b/src/wispr.c
@@ -158,7 +158,10 @@  static void free_wispr_routes(struct connman_wispr_portal_context *wp_context)
 		}
 
 		g_free(route->address);
+		route->address = NULL;
+
 		g_free(route);
+		wp_context->route_list->data = NULL;
 
 		wp_context->route_list =
 			g_slist_delete_link(wp_context->route_list,