Fix pointer corruption in gatt_server_deinitialize 82/281982/1 accepted/tizen/6.0/unified/20220927.070331 submit/tizen_6.0/20220926.043134
authorAyush Garg <ayush.garg@samsung.com>
Fri, 3 Dec 2021 10:40:05 +0000 (16:10 +0530)
committerWootak Jung <wootak.jung@samsung.com>
Mon, 26 Sep 2022 00:49:28 +0000 (09:49 +0900)
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 8c43fcd56b5ec1a04974837f1137057bde397bef..1a05bee5ac7ffc9ac2ecc4fbb3830f70bf22f45b 100644 (file)
@@ -2685,8 +2685,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);