From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31285 invoked by alias); 18 Mar 2014 07:39:54 -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 31272 invoked by uid 89); 18 Mar 2014 07:39:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Mar 2014 07:39:51 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1WPocl-0005sm-NP from Hui_Zhu@mentor.com for gdb-patches@sourceware.org; Tue, 18 Mar 2014 00:39:47 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Tue, 18 Mar 2014 00:39:47 -0700 Received: from localhost.localdomain (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.2.247.3; Tue, 18 Mar 2014 00:39:46 -0700 Message-ID: <5327F83C.8070405@mentor.com> Date: Tue, 18 Mar 2014 07:39:00 -0000 From: Hui Zhu User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: gdb-patches ml Subject: Re: [PATCH 1/1] Fix memleak of the pid_to_exec_file target_ops method for some platforms References: <53271C09.5000709@mentor.com> <53271C80.1040103@mentor.com> In-Reply-To: <53271C80.1040103@mentor.com> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2014-03/txt/msg00408.txt.bz2 I just posted a new version for [patch 0/1] that include this patch. So please ignore it. Thanks, Hui On 03/18/14 00:02, Hui Zhu wrote: > I said most of the pid_to_exec_file target_ops method for some platforms will > allocate memory for exec_file and add them to cleanup. > But some of them didn't do that. > So I make a patch to fix this memleak. > > Thanks, > Hui > > 2014-03-17 Hui Zhu > > * fbsd-nat.c (fbsd_pid_to_exec_file): Add make_cleanup. > * nbsd-nat.c (nbsd_pid_to_exec_file): Ditto. > > --- a/gdb/fbsd-nat.c > +++ b/gdb/fbsd-nat.c > @@ -43,6 +43,8 @@ fbsd_pid_to_exec_file (struct target_ops > char *buf = xcalloc (len, sizeof (char)); > char *path; > > + make_cleanup (xfree, buf); > + > #ifdef KERN_PROC_PATHNAME > int mib[4]; > > --- a/gdb/nbsd-nat.c > +++ b/gdb/nbsd-nat.c > @@ -31,6 +31,8 @@ nbsd_pid_to_exec_file (struct target_ops > char *buf = xcalloc (len, sizeof (char)); > char *path; > > + make_cleanup (xfree, buf); > + > path = xstrprintf ("/proc/%d/exe", pid); > if (readlink (path, buf, PATH_MAX - 1) == -1) > { >