Fix pointer corruption in gatt_server_deinitialize 32/267432/1
authorAyush Garg <ayush.garg@samsung.com>
Fri, 3 Dec 2021 10:40:05 +0000 (16:10 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 3 Dec 2021 10:40:05 +0000 (16:10 +0530)
The next node pointer of the gatt_server_list must be
stored before removing the current node.

Change-Id: I416a3a17d0c314f246449d6f458cffe6daaff2c3

src/bluetooth-gatt.c

index 33b0b47..5e0791f 100644 (file)
@@ -2725,8 +2725,9 @@ int bt_gatt_server_deinitialize(void)
 
        if (is_gatt_server_initialized) {
                GSList *l;
-               for (l = gatt_server_list; l; l = g_slist_next(l)) {
+               for (l = gatt_server_list; l;) {
                        bt_gatt_server_s *serv = l->data;
+                       l = g_slist_next(l);
                        bt_gatt_server_destroy(serv);
                }
                g_slist_free(gatt_server_list);