From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93555 invoked by alias); 17 Feb 2016 17:02:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 93544 invoked by uid 89); 17 Feb 2016 17:02:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=1417 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 17 Feb 2016 17:02:21 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id C973A70D6B; Wed, 17 Feb 2016 17:02:19 +0000 (UTC) Received: from blade.nx (ovpn-116-100.ams2.redhat.com [10.36.116.100]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1HH2Ii9017790; Wed, 17 Feb 2016 12:02:19 -0500 Received: from blade.nx (localhost [127.0.0.1]) by blade.nx (Postfix) with ESMTP id 80EB62643E8; Wed, 17 Feb 2016 17:02:17 +0000 (GMT) From: Gary Benson To: gdb-patches@sourceware.org Cc: Pedro Alves , Luis Machado Subject: [OB PATCH] Add missing cleanup in exec_file_locate_attach Date: Wed, 17 Feb 2016 17:02:00 -0000 Message-Id: <1455728537-27577-1-git-send-email-gbenson@redhat.com> In-Reply-To: <20160217135324.GC24631@blade.nx> References: <20160217135324.GC24631@blade.nx> X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg00524.txt.bz2 Hi all, exec_file_locate_attach allocates memory for full_exec_path (using either exec_file_find, source_full_path_of or xstrdup) but this memory is never freed. This commit adds the necessary cleanup. Pushed as obvious. Cheers, Gary -- gdb/ChangeLog: * exec.c (exec_file_locate_attach): Add missing cleanup. --- gdb/ChangeLog | 4 ++++ gdb/exec.c | 5 +++++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index 23c89c2..0b8c077 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -141,6 +141,7 @@ void exec_file_locate_attach (int pid, int from_tty) { char *exec_file, *full_exec_path = NULL; + struct cleanup *old_chain; /* Do nothing if we already have an executable filename. */ exec_file = (char *) get_exec_file (0); @@ -170,8 +171,12 @@ exec_file_locate_attach (int pid, int from_tty) full_exec_path = xstrdup (exec_file); } + old_chain = make_cleanup (xfree, full_exec_path); + exec_file_attach (full_exec_path, from_tty); symbol_file_add_main (full_exec_path, from_tty); + + do_cleanups (old_chain); } /* Set FILENAME as the new exec file. -- 1.7.1