Once the current list item has been freed, do not access it anymore.
Ensure that the list is advanced to the next item.
---
 src/agent.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/agent.c b/src/agent.c
index 361a5e1..bdeb0e7 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -502,7 +502,7 @@ void connman_agent_cancel(void *user_context)
 
        g_hash_table_iter_init(&iter, agent_hash);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
-               GList *list;
+               GList *list, *next;
                struct connman_agent *agent = value;
 
                /*
@@ -512,6 +512,8 @@ void connman_agent_cancel(void *user_context)
                while (list) {
                        struct connman_agent_request *request = list->data;
 
+                       next = list->next;
+
                        if (request && request->user_context &&
                                                request->user_context ==
                                                                user_context) {
@@ -523,8 +525,9 @@ void connman_agent_cancel(void *user_context)
 
                                agent->queue = g_list_delete_link(agent->queue,
                                                                        list);
-                       } else
-                               list = list->next;
+                       }
+
+                       list = next;
                }
 
                /*
-- 
2.1.4

_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman

Reply via email to