Blame SOURCES/0029-channel-main-Copy-SpiceMigrationDstInfo-into-spice_m.patch

7492b2
From ab42be2b00d12d0bc98c6ddea08a7f969e83b2ac Mon Sep 17 00:00:00 2001
7492b2
From: Frediano Ziglio <freddy77@gmail.com>
7492b2
Date: Mon, 10 Aug 2020 15:35:26 +0100
7492b2
Subject: [PATCH 29/31] channel-main: Copy SpiceMigrationDstInfo into
7492b2
 spice_migrate
7492b2
7492b2
The message could disappear while the structure is used.
7492b2
7492b2
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
7492b2
Acked-by: Uri Lublin <uril@redhat.com>
7492b2
---
7492b2
 src/channel-main.c | 15 +++++++++++----
7492b2
 1 file changed, 11 insertions(+), 4 deletions(-)
7492b2
7492b2
diff --git a/src/channel-main.c b/src/channel-main.c
7492b2
index 8caf727..5f81975 100644
7492b2
--- a/src/channel-main.c
7492b2
+++ b/src/channel-main.c
7492b2
@@ -121,7 +121,7 @@ struct _SpiceMainChannelPrivate  {
7492b2
 
7492b2
 struct spice_migrate {
7492b2
     struct coroutine *from;
7492b2
-    SpiceMigrationDstInfo *info;
7492b2
+    SpiceMigrationDstInfo info;
7492b2
     SpiceSession *session;
7492b2
     int ref_count;
7492b2
     guint nchannels;
7492b2
@@ -2258,6 +2258,8 @@ static void
7492b2
 spice_migrate_unref(spice_migrate *mig)
7492b2
 {
7492b2
     if (mig != NULL && --mig->ref_count == 0) {
7492b2
+        g_free(mig->info.host_data);
7492b2
+        g_free(mig->info.cert_subject_data);
7492b2
         g_free(mig);
7492b2
     }
7492b2
 }
7492b2
@@ -2396,7 +2398,6 @@ static gboolean migrate_connect(spice_migrate *mig)
7492b2
     const char *host;
7492b2
 
7492b2
     g_return_val_if_fail(mig != NULL, FALSE);
7492b2
-    g_return_val_if_fail(mig->info != NULL, FALSE);
7492b2
     g_return_val_if_fail(mig->nchannels == 0, FALSE);
7492b2
     c = SPICE_CHANNEL(mig->src_channel)->priv;
7492b2
     g_return_val_if_fail(c != NULL, FALSE);
7492b2
@@ -2404,7 +2405,7 @@ static gboolean migrate_connect(spice_migrate *mig)
7492b2
 
7492b2
     spice_session_set_migration_state(mig->session, SPICE_SESSION_MIGRATION_CONNECTING);
7492b2
 
7492b2
-    SpiceMigrationDstInfo *info = mig->info;
7492b2
+    SpiceMigrationDstInfo *info = &mig->info;
7492b2
     SPICE_DEBUG("migrate_begin %u %s %d %d",
7492b2
                 info->host_size, info->host_data, info->port, info->sport);
7492b2
     port = info->port;
7492b2
@@ -2461,7 +2462,13 @@ static void main_migrate_connect(SpiceChannel *channel,
7492b2
     mig = spice_new0(spice_migrate, 1);
7492b2
     mig->ref_count = 1;
7492b2
     mig->src_channel = channel;
7492b2
-    mig->info = dst_info;
7492b2
+    mig->info = *dst_info;
7492b2
+    if (dst_info->host_data) {
7492b2
+        mig->info.host_data = (void *) g_strdup((char*) dst_info->host_data);
7492b2
+    }
7492b2
+    if (dst_info->cert_subject_data) {
7492b2
+        mig->info.cert_subject_data = (void *) g_strdup((char*) dst_info->cert_subject_data);
7492b2
+    }
7492b2
     mig->from = coroutine_self();
7492b2
     mig->do_seamless = do_seamless;
7492b2
     mig->src_mig_version = src_mig_version;
7492b2
-- 
7492b2
2.28.0
7492b2