diff mbox series

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

Message ID 20231119170714.775270-17-gerickson@nuovations.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Address Redundant IPv4 Reachability Checks | expand

Commit Message

Grant Erickson Nov. 19, 2023, 5:07 p.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 3837a87811a9..9cd1e7db501d 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,