[Spice-devel,v4,6/7] Free properly primary surface during replay

Submitted by Frediano Ziglio on Dec. 2, 2016, 5:43 p.m.

Details

Message ID 1939f7a3b597b72e83979d4b13dfc76a71bc0dde.1480700546.git-series.fziglio@redhat.com
State Accepted
Headers show
Series "Start cleaning objects on destruction" ( rev: 6 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Dec. 2, 2016, 5:43 p.m.
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Pavel Grunt <pgrunt@redhat.com>
---
 server/red-replay-qxl.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/server/red-replay-qxl.c b/server/red-replay-qxl.c
index 2176068..aeaa545 100644
--- a/server/red-replay-qxl.c
+++ b/server/red-replay-qxl.c
@@ -48,6 +48,7 @@  struct SpiceReplay {
     GArray *id_map; // record id -> replay id
     GArray *id_map_inv; // replay id -> record id
     GArray *id_free; // free list
+    uint8_t *primary_mem;
     int nsurfaces;
     int end_pos;
 
@@ -1254,6 +1255,8 @@  static void replay_handle_create_primary(QXLWorker *worker, SpiceReplay *replay)
     }
     read_binary(replay, "data", &size, &mem, 0);
     surface.group_id = 0;
+    free(replay->primary_mem);
+    replay->primary_mem = mem;
     surface.mem = QXLPHYSICAL_FROM_PTR(mem);
     worker->create_primary_surface(worker, 0, &surface);
 }
@@ -1269,6 +1272,8 @@  static void replay_handle_dev_input(QXLWorker *worker, SpiceReplay *replay,
     case RED_WORKER_MESSAGE_DESTROY_PRIMARY_SURFACE:
         replay->created_primary = FALSE;
         worker->destroy_primary_surface(worker, 0);
+        free(replay->primary_mem);
+        replay->primary_mem = NULL;
         break;
     case RED_WORKER_MESSAGE_DESTROY_SURFACES:
         replay->created_primary = FALSE;
@@ -1454,6 +1459,7 @@  SPICE_GNUC_VISIBLE void spice_replay_free(SpiceReplay *replay)
     g_array_free(replay->id_map, TRUE);
     g_array_free(replay->id_map_inv, TRUE);
     g_array_free(replay->id_free, TRUE);
+    free(replay->primary_mem);
     fclose(replay->fd);
     free(replay);
 }