From patchwork Fri Dec 14 19:12:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 30671 Received: (qmail 11580 invoked by alias); 14 Dec 2018 19:12:48 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 11466 invoked by uid 89); 14 Dec 2018 19:12:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=U*palves, sk:palves, sk:palves@, palvesredhatcom X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Dec 2018 19:12:46 +0000 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5BFFC0A1B1B for ; Fri, 14 Dec 2018 19:12:45 +0000 (UTC) Received: from localhost.localdomain (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BFAD5D756 for ; Fri, 14 Dec 2018 19:12:45 +0000 (UTC) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 2/3] Fix leak in solib-target.c:library_list_start_library Date: Fri, 14 Dec 2018 19:12:41 +0000 Message-Id: <20181214191242.21560-3-palves@redhat.com> In-Reply-To: <20181214191242.21560-1-palves@redhat.com> References: <20181214191242.21560-1-palves@redhat.com> lm_info_target::name is nowadays std::string, so we're leaking the result of xstrdup. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * solib-target.c (library_list_start_library): Don't xstrdup name. --- gdb/solib-target.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gdb/solib-target.c b/gdb/solib-target.c index 3c9872c116..6a395ad378 100644 --- a/gdb/solib-target.c +++ b/gdb/solib-target.c @@ -124,10 +124,9 @@ library_list_start_library (struct gdb_xml_parser *parser, { VEC(lm_info_target_p) **list = (VEC(lm_info_target_p) **) user_data; lm_info_target *item = new lm_info_target; - const char *name + item->name = (const char *) xml_find_attribute (attributes, "name")->value.get (); - item->name = xstrdup (name); VEC_safe_push (lm_info_target_p, *list, item); }