From patchwork Mon Jun 20 15:00:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 9187715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78BF96075E for ; Mon, 20 Jun 2016 15:01:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64F5D20747 for ; Mon, 20 Jun 2016 15:01:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 570B82793B; Mon, 20 Jun 2016 15:01:16 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 2750320747 for ; Mon, 20 Jun 2016 15:01:15 +0000 (UTC) Received: from localhost ([::1]:44179 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0hN-0001M1-QH for patchwork-qemu-devel@patchwork.kernel.org; Mon, 20 Jun 2016 11:01:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0gi-0001Gd-8h for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bF0gf-00022Y-HY for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:00:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bF0gf-00022C-AE for qemu-devel@nongnu.org; Mon, 20 Jun 2016 11:00:29 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6ABBCC0740E5 for ; Mon, 20 Jun 2016 15:00:28 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5KF0QjC022770 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Mon, 20 Jun 2016 11:00:28 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E17E611386B2; Mon, 20 Jun 2016 17:00:23 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 20 Jun 2016 17:00:21 +0200 Message-Id: <1466434823-22789-6-git-send-email-armbru@redhat.com> In-Reply-To: <1466434823-22789-1-git-send-email-armbru@redhat.com> References: <1466434823-22789-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 20 Jun 2016 15:00:28 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/7] log: Plug memory leak on multiple -dfilter 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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP -dfilter overwrites any previous filter. The overwritten filter is leaked. Leaks since the beginning (commit 3514552, v2.6.0). Free it properly. Signed-off-by: Markus Armbruster Message-Id: <1466011636-6112-2-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake --- util/log.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/log.c b/util/log.c index 5ad72c1..6f45e0a 100644 --- a/util/log.c +++ b/util/log.c @@ -145,9 +145,16 @@ bool qemu_log_in_addr_range(uint64_t addr) void qemu_set_dfilter_ranges(const char *filter_spec) { gchar **ranges = g_strsplit(filter_spec, ",", 0); + + if (debug_regions) { + g_array_unref(debug_regions); + debug_regions = NULL; + } + if (ranges) { gchar **next = ranges; gchar *r = *next++; + debug_regions = g_array_sized_new(FALSE, FALSE, sizeof(Range), g_strv_length(ranges)); while (r) {