[PATCH] dcc: free glz buffer after zlib compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For zlib+glz compression image if first compressed with glz then the
resulting buffer is compressed again with zlib then the buffer from
zlib is returned to the caller.
However the temporary glz buffer was not freed resulting in a memory
leak.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/dcc.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/server/dcc.c b/server/dcc.c
index 7c16fc0..1a6a865 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -662,6 +662,9 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
     int glz_size;
     int zlib_size;
 
+    spice_assert(glz_data->data.bufs_tail == NULL);
+    spice_assert(glz_data->data.bufs_head == NULL);
+
     glz_data->data.bufs_tail = compress_buf_new();
     glz_data->data.bufs_head = glz_data->data.bufs_tail;
     glz_data->data.dcc = dcc;
@@ -708,6 +711,13 @@ int dcc_compress_image_glz(DisplayChannelClient *dcc,
             compress_buf_free(buf);
         }
         goto glz;
+    } else {
+        while (glz_data->data.bufs_head) {
+            RedCompressBuf *buf = glz_data->data.bufs_head;
+            glz_data->data.bufs_head = buf->send_next;
+            compress_buf_free(buf);
+        }
+        glz_data->data.bufs_head = glz_data->data.bufs_tail = NULL;
     }
 
     dest->descriptor.type = SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB;
@@ -725,6 +735,7 @@ glz:
 
     o_comp_data->comp_buf = glz_data->data.bufs_head;
     o_comp_data->comp_buf_size = glz_size;
+    glz_data->data.bufs_head = glz_data->data.bufs_tail = NULL;
 
     return TRUE;
 }
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]