From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=34936 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWZoe-00086c-Ei for qemu-devel@nongnu.org; Wed, 07 Jul 2010 14:57:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWZoc-0002fj-3R for qemu-devel@nongnu.org; Wed, 07 Jul 2010 14:57:52 -0400 Received: from iksaif.net ([88.191.73.63]:35191) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWZob-0002eq-U3 for qemu-devel@nongnu.org; Wed, 07 Jul 2010 14:57:50 -0400 From: Corentin Chary Date: Wed, 7 Jul 2010 20:57:55 +0200 Message-Id: <1278529086-10391-8-git-send-email-corentincj@iksaif.net> In-Reply-To: <1278529086-10391-1-git-send-email-corentincj@iksaif.net> References: <1278529086-10391-1-git-send-email-corentincj@iksaif.net> Subject: [Qemu-devel] [PATCH v2 07/18] vnc: tight: remove a memleak in send_jpeg_rect() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Corentin Chary , Anthony Liguori , Alexander Graf buf was never freed. Signed-off-by: Corentin Chary --- ui/vnc-enc-tight.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c index ade8e5f..4ff88a8 100644 --- a/ui/vnc-enc-tight.c +++ b/ui/vnc-enc-tight.c @@ -1247,8 +1247,6 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality) if (ds_get_bytes_per_pixel(vs->ds) == 1) return send_full_color_rect(vs, w, h); - buf = qemu_malloc(w * 3); - row[0] = buf; buffer_reserve(&vs->tight_jpeg, 2048); cinfo.err = jpeg_std_error(&jerr); @@ -1270,10 +1268,13 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality) jpeg_start_compress(&cinfo, true); + buf = qemu_malloc(w * 3); + row[0] = buf; for (dy = 0; dy < h; dy++) { jpeg_prepare_row(vs, buf, x, y + dy, w); jpeg_write_scanlines(&cinfo, row, 1); } + qemu_free(buf); jpeg_finish_compress(&cinfo); jpeg_destroy_compress(&cinfo); -- 1.7.1