From patchwork Wed Jun 16 07:12:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 55846 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 D83231007D2 for ; Wed, 16 Jun 2010 16:22:47 +1000 (EST) Received: from localhost ([127.0.0.1]:37526 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOm1M-0006e2-QI for incoming@patchwork.ozlabs.org; Wed, 16 Jun 2010 02:22:44 -0400 Received: from [140.186.70.92] (port=53291 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOlqx-0001rW-AG for qemu-devel@nongnu.org; Wed, 16 Jun 2010 02:12:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOlqu-00031L-9K for qemu-devel@nongnu.org; Wed, 16 Jun 2010 02:11:59 -0400 Received: from iksaif.net ([88.191.73.63]:35951) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOlqu-00030v-51 for qemu-devel@nongnu.org; Wed, 16 Jun 2010 02:11:56 -0400 Received: from tartiflon (lal69-3-82-241-209-44.fbx.proxad.net [82.241.209.44]) (Authenticated sender: corentincj@iksaif.net) by iksaif.net (Postfix) with ESMTPA id 48A66C90084; Wed, 16 Jun 2010 08:16:17 +0200 (CEST) From: Corentin Chary To: qemu-devel@nongnu.org Date: Wed, 16 Jun 2010 09:12:04 +0200 Message-Id: <1276672333-14831-8-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1276672333-14831-1-git-send-email-corentincj@iksaif.net> References: <1276672333-14831-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 Subject: [Qemu-devel] [PATCH 07/16] vnc: tight: remove a memleak in send_jpeg_rect() 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 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);