From patchwork Tue Aug 7 22:18:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Wu X-Patchwork-Id: 10559281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5330F157B for ; Tue, 7 Aug 2018 22:19:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D2F92A476 for ; Tue, 7 Aug 2018 22:19:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F7202A48C; Tue, 7 Aug 2018 22:19:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 576DE2A476 for ; Tue, 7 Aug 2018 22:19:22 +0000 (UTC) Received: from localhost ([::1]:41044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnAK1-000302-4Q for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Aug 2018 18:19:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnAJJ-0002hA-KV for qemu-devel@nongnu.org; Tue, 07 Aug 2018 18:18:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnAJI-00030h-Mk for qemu-devel@nongnu.org; Tue, 07 Aug 2018 18:18:37 -0400 Received: from mail.lekensteyn.nl ([2a02:2308::360:1:25]:39189) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fnAJI-0002zp-Cb; Tue, 07 Aug 2018 18:18:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lekensteyn.nl; s=s2048-2015-q1; h=Message-Id:Date:Subject:Cc:To:From; bh=ts+ynJxEGifjDQ4UDe13LlLpEYFbHnFQHIj0MqTjsQs=; b=C1mdznG8C40hGckr418b83mgmt5oJeox4dqAX/d87ZXFjrZ7ims4mkDH4SNqULc9ifllXE90cxmDV4qFFFWkombqJB6fOdSmMeszwOES1rAfQq7efq+1rANP2ImjujizA0tZxD/8FsNB/myTR9wYVXeamKNavB0HdOr6ZD4fqr4wc8S28a8a09z+fO/Wpnx+H3sBJaxAfO9ycyLWdxnu/CXKjAedr5+W0GfUpJ87psNLD4FZDlkDm8KNQwJ5kM7NeudB7xW5fdXLMDn6fojpENWv3QLmqpuOnf5b+o7Xs6eLZxc4/GtyEV4yrjhQgRtDTuH9iPwN+Ci1E+mIfy3GzA==; Received: by lekensteyn.nl with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1fnAJE-0006q5-99; Wed, 08 Aug 2018 00:18:32 +0200 From: Peter Wu To: qemu-devel@nongnu.org Date: Wed, 8 Aug 2018 00:18:30 +0200 Message-Id: <20180807221830.3844-1-peter@lekensteyn.nl> X-Mailer: git-send-email 2.18.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a02:2308::360:1:25 Subject: [Qemu-devel] [PATCH] vnc: fix memleak of the "vnc-worker-output" name X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fixes repeated memory leaks of 18 bytes when using VNC: Direct leak of 831024 byte(s) in 46168 object(s) allocated from: ... #4 0x7f6d2f919bdd in g_strdup_vprintf glib/gstrfuncs.c:514 #5 0x56085cdcf660 in buffer_init util/buffer.c:59 #6 0x56085ca6a7ec in vnc_async_encoding_start ui/vnc-jobs.c:177 #7 0x56085ca6b815 in vnc_worker_thread_loop ui/vnc-jobs.c:240 Fixes: 543b95801f98 ("vnc: attach names to buffers") Cc: Gerd Hoffmann CC: qemu-stable@nongnu.org Signed-off-by: Peter Wu Reviewed-by: Marc-André Lureau --- ui/vnc-jobs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/vnc-jobs.c b/ui/vnc-jobs.c index b0b15d42a8..929391f85d 100644 --- a/ui/vnc-jobs.c +++ b/ui/vnc-jobs.c @@ -193,6 +193,7 @@ static void vnc_async_encoding_start(VncState *orig, VncState *local) static void vnc_async_encoding_end(VncState *orig, VncState *local) { + buffer_free(&local->output); orig->tight = local->tight; orig->zlib = local->zlib; orig->hextile = local->hextile; @@ -278,7 +279,7 @@ static int vnc_worker_thread_loop(VncJobQueue *queue) /* Copy persistent encoding data */ vnc_async_encoding_end(job->vs, &vs); - qemu_bh_schedule(job->vs->bh); + qemu_bh_schedule(job->vs->bh); } else { buffer_reset(&vs.output); /* Copy persistent encoding data */