From patchwork Wed May 19 07:24:08 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 52957 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C2C76B7D6A for ; Wed, 19 May 2010 17:34:49 +1000 (EST) Received: from localhost ([127.0.0.1]:45548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEdlP-0001dD-O9 for incoming@patchwork.ozlabs.org; Wed, 19 May 2010 03:32:23 -0400 Received: from [140.186.70.92] (port=54622 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OEdaB-0004AP-0R for qemu-devel@nongnu.org; Wed, 19 May 2010 03:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OEdZw-0008Nt-5V for qemu-devel@nongnu.org; Wed, 19 May 2010 03:20:46 -0400 Received: from iksaif.net ([88.191.73.63]:39153) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OEdZu-0008N4-GM for qemu-devel@nongnu.org; Wed, 19 May 2010 03:20:30 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id 1A4C0C90038; Wed, 19 May 2010 09:24:14 +0200 (CEST) From: Corentin Chary To: qemu-devel@nongnu.org Date: Wed, 19 May 2010 09:24:08 +0200 Message-Id: <1274253852-16068-9-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.0.2 In-Reply-To: <1274253852-16068-1-git-send-email-corentincj@iksaif.net> References: <1274253852-16068-1-git-send-email-corentincj@iksaif.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Corentin Chary , Anthony Liguori , Alexander Graf , Adam Litke Subject: [Qemu-devel] [PATCH v3 08/12] vnc: remove a memory leak in zlib X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Makes sure we free all ressources used in zlib encoding (zlib stream and buffer). Signed-off-by: Corentin Chary --- vnc-encoding-zlib.c | 8 ++++++++ vnc.c | 2 ++ vnc.h | 1 + 3 files changed, 11 insertions(+), 0 deletions(-) diff --git a/vnc-encoding-zlib.c b/vnc-encoding-zlib.c index 52b18aa..1d4dd1a 100644 --- a/vnc-encoding-zlib.c +++ b/vnc-encoding-zlib.c @@ -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 8f256b3..d622a5a 100644 --- a/vnc.c +++ b/vnc.c @@ -924,6 +924,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 abd9f27..ffcbc52 100644 --- a/vnc.h +++ b/vnc.h @@ -399,5 +399,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 */