[Spice-devel] [PATCH 1/2 v2] dcc: free glz buffer after zlib compression

Frediano Ziglio fziglio at redhat.com
Thu Jan 7 08:30:21 PST 2016


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 at redhat.com>
---
 server/dcc.c | 7 +++++++
 1 file changed, 7 insertions(+)

Changes from v1:
- removed useless code.

diff --git a/server/dcc.c b/server/dcc.c
index 7c16fc0..7348627 100644
--- a/server/dcc.c
+++ b/server/dcc.c
@@ -708,6 +708,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_tail = NULL;
     }
 
     dest->descriptor.type = SPICE_IMAGE_TYPE_ZLIB_GLZ_RGB;
-- 
2.4.3



More information about the Spice-devel mailing list