[Spice-devel,v2,19/19] Free properly primary surface during replay

Submitted by Frediano Ziglio on Nov. 25, 2016, 2:52 p.m.

Details

Message ID dad766c901c0da2bdc1332e6c6c423b4eb7a46f7.1480085518.git-series.fziglio@redhat.com
State Superseded
Headers show
Series "Start cleaning objects on destruction" ( rev: 4 3 2 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio Nov. 25, 2016, 2:52 p.m.
Signed-off-by: Frediano Ziglio <fziglio@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);
 }

Comments

On Fri, 2016-11-25 at 14:52 +0000, Frediano Ziglio wrote:
> 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(+)
> 
> 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);
>  }