[Spice-commits] server/reds.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 12 14:16:12 UTC 2018


 server/reds.c |   14 ++++++++++++++
 1 file changed, 14 insertions(+)

New commits:
commit bc14aaecd793640bf4a957ee6336b6e080ef1894
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Wed Jul 11 16:33:51 2018 +0100

    reds: Free device chain in spice_server_destroy to avoid leaks
    
    Leak detectors did not manage to find leaks, possibly as double list
    have all elements likely with a pointer to them.
    The reference from the agent is necessary for inserting it into
    the list.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index f1e34529..85043a88 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -3132,6 +3132,7 @@ static int spice_server_char_device_add_interface(SpiceServer *reds,
             return -1;
         }
         dev_state = attach_to_red_agent(reds, char_device);
+        g_object_ref(dev_state);
     }
 #ifdef USE_SMARTCARD
     else if (strcmp(char_device->subtype, SUBTYPE_SMARTCARD) == 0) {
@@ -3682,6 +3683,19 @@ SPICE_GNUC_VISIBLE void spice_server_destroy(SpiceServer *reds)
     }
     reds_cleanup_net(reds);
     g_clear_object(&reds->agent_dev);
+
+    // NOTE: don't replace with g_list_free_full as this function that passed callback
+    // don't change the list while g_object_unref in this case will change it.
+    RedCharDevice *dev;
+    GLIST_FOREACH(reds->char_devices, RedCharDevice, dev) {
+        g_object_unref(dev);
+    }
+    g_list_free(reds->char_devices);
+    reds->char_devices = NULL;
+
+    g_list_free(reds->channels);
+    reds->channels = NULL;
+
     spice_buffer_free(&reds->client_monitors_config);
     red_record_unref(reds->record);
     reds_cleanup(reds);


More information about the Spice-commits mailing list