vnc: remove a memory leak in zlib
authorCorentin Chary <corentincj@iksaif.net>
Wed, 19 May 2010 07:24:08 +0000 (09:24 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 1 Jun 2010 17:53:09 +0000 (12:53 -0500)
Makes sure we free all ressources used in zlib encoding (zlib stream
and buffer).

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vnc-encoding-zlib.c
vnc.c
vnc.h

index 52b18aa84ae7aa4a85a591157304eddbf9fec03b..1d4dd1aa47f6afcaa878f1fb82623ec79d58b53f 100644 (file)
@@ -140,3 +140,11 @@ void vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)
     vnc_write_u32(vs, bytes_written);
     vs->output.offset = new_offset;
 }
+
+void vnc_zlib_clear(VncState *vs)
+{
+    if (vs->zlib_stream.opaque) {
+        deflateEnd(&vs->zlib_stream);
+    }
+    buffer_free(&vs->zlib);
+}
diff --git a/vnc.c b/vnc.c
index 6b2f7241a810e95d910fca1d68bef87d22017e70..f48f25367586e30c0ee25ba9b9348fa75992281d 100644 (file)
--- a/vnc.c
+++ b/vnc.c
@@ -974,6 +974,8 @@ static void vnc_disconnect_finish(VncState *vs)
 
     qobject_decref(vs->info);
 
+    vnc_zlib_clear(vs);
+
 #ifdef CONFIG_VNC_TLS
     vnc_tls_client_cleanup(vs);
 #endif /* CONFIG_VNC_TLS */
diff --git a/vnc.h b/vnc.h
index c97113b8ea500c9b71c7dc8b8fefb6986cbe10cd..2fbe614484457b6e8ccadb56f3f67d7afc9aecc4 100644 (file)
--- a/vnc.h
+++ b/vnc.h
@@ -405,5 +405,6 @@ void vnc_hextile_send_framebuffer_update(VncState *vs, int x,
 void vnc_hextile_set_pixel_conversion(VncState *vs, int generic);
 
 void vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);
+void vnc_zlib_clear(VncState *vs);
 
 #endif /* __QEMU_VNC_H */