Fix SIGSEV on freeing server domains list 57/310857/4
authorDaniil Ruban <intx82@gmail.com>
Thu, 9 May 2024 05:00:42 +0000 (07:00 +0200)
committerDaniil Ruban <intx82@gmail.com>
Thu, 9 May 2024 10:25:27 +0000 (12:25 +0200)
- Fix changes freeing server domain list to use 'g_list_free_full' instead of for-loop

Change-Id: I0e54a96ed29505bbb1537f6779095d32314be075
Signed-off-by: Daniil Ruban <intx82@gmail.com>
src/dnsproxy.c

index 8e3ce97..625ec06 100755 (executable)
@@ -2679,6 +2679,8 @@ static void destroy_server_sec(struct server_data *server)
 {
        GList *list;
        int fd;
+       if (server == NULL)
+               return;
 
        if (server->channel)
                fd = g_io_channel_unix_get_fd(server->channel);
@@ -2698,12 +2700,9 @@ static void destroy_server_sec(struct server_data *server)
                DBG("Removing DNS server %s", server->server);
 
        g_free(server->server);
-       for (list = server->domains; list; list = list->next) {
-               char *domain = list->data;
 
-               server->domains = g_list_remove(server->domains, domain);
-               g_free(domain);
-       }
+       g_list_free_full(server->domains, g_free);
+
        g_free(server->server_addr);
 
        /*