[Spice-commits] server/reds.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Feb 29 09:26:29 UTC 2020


 server/reds.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

New commits:
commit 68c514e1faa4438888e6d70f969eb8fc2149a477
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Tue Dec 10 14:59:39 2019 +0000

    reds: Free RedLinkInfo once in reds_handle_link
    
    Instead of freeing it in both reds_handle_main_link and
    reds_handle_other_links free it in reds_handle_link.
    This will reduce the chances code is changed adding a leak in some paths.
    
    Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
    Acked-by: Julien Rope <jrope at redhat.com>

diff --git a/server/reds.c b/server/reds.c
index 9fbcd8fa..4e23337c 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1886,8 +1886,6 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
     reds_info_new_channel(link, connection_id);
     stream = link->stream;
     link->stream = NULL;
-    link->link_mess = NULL;
-    reds_link_free(link);
     client = red_client_new(reds, mig_target);
     reds->clients = g_list_prepend(reds->clients, client);
 
@@ -1897,7 +1895,6 @@ static void reds_handle_main_link(RedsState *reds, RedLinkInfo *link)
                             &caps);
     red_channel_capabilities_reset(&caps);
     spice_debug("NEW Client %p mcc %p connect-id %d", client, mcc, connection_id);
-    g_free(link_mess);
 
     if (reds->vdagent) {
         if (mig_target) {
@@ -2072,7 +2069,6 @@ static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)
     // where do we store it? on reds, but should be a list (MC).
     if (!client) {
         reds_send_link_result(link, SPICE_LINK_ERR_BAD_CONNECTION_ID);
-        reds_link_free(link);
         return;
     }
 
@@ -2080,7 +2076,6 @@ static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)
     if (!(channel = reds_find_channel(reds, link_mess->channel_type,
                                       link_mess->channel_id))) {
         reds_send_link_result(link, SPICE_LINK_ERR_CHANNEL_NOT_AVAILABLE);
-        reds_link_free(link);
         return;
     }
 
@@ -2107,7 +2102,6 @@ static void reds_handle_other_links(RedsState *reds, RedLinkInfo *link)
         reds_channel_do_link(channel, client, link_mess, link->stream);
     }
     link->stream = NULL;
-    reds_link_free(link);
 }
 
 static void reds_handle_link(RedLinkInfo *link)
@@ -2120,6 +2114,7 @@ static void reds_handle_link(RedLinkInfo *link)
     } else {
         reds_handle_other_links(reds, link);
     }
+    reds_link_free(link);
 }
 
 static void reds_handle_ticket(void *opaque)


More information about the Spice-commits mailing list