[Spice-devel] [PATCH] char_device.c: fix call to spice_marshaller_add_ref with memory on stack

Yonit Halperin yhalperi at redhat.com
Wed Nov 21 11:53:25 PST 2012


rhbz#862352
---
 server/char_device.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/server/char_device.c b/server/char_device.c
index ac2632d..141ec88 100644
--- a/server/char_device.c
+++ b/server/char_device.c
@@ -816,12 +816,14 @@ void spice_char_device_wakeup(SpiceCharDeviceState *dev)
 
 void spice_char_device_state_migrate_data_marshall_empty(SpiceMarshaller *m)
 {
-    SpiceMigrateDataCharDevice mig_data;
-
-    memset(&mig_data, 0, sizeof(mig_data));
-    mig_data.version = SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION;
-    mig_data.connected = FALSE;
-    spice_marshaller_add_ref(m, (uint8_t *)&mig_data, sizeof(SpiceMigrateDataCharDevice));
+    SpiceMigrateDataCharDevice *mig_data;
+
+    spice_debug(NULL);
+    mig_data = (SpiceMigrateDataCharDevice *)spice_marshaller_reserve_space(m,
+                                                                            sizeof(*mig_data));
+    memset(mig_data, 0, sizeof(*mig_data));
+    mig_data->version = SPICE_MIGRATE_DATA_CHAR_DEVICE_VERSION;
+    mig_data->connected = FALSE;
 }
 
 void spice_char_device_state_migrate_data_marshall(SpiceCharDeviceState *dev,
-- 
1.7.11.7



More information about the Spice-devel mailing list