From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9857 invoked by alias); 4 Jul 2008 06:40:13 -0000 Received: (qmail 9801 invoked by uid 22791); 4 Jul 2008 06:40:10 -0000 X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.185) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 04 Jul 2008 06:39:49 +0000 Received: by ti-out-0910.google.com with SMTP id d10so56543tib.12 for ; Thu, 03 Jul 2008 23:39:46 -0700 (PDT) Received: by 10.110.47.17 with SMTP id u17mr29346tiu.46.1215153586115; Thu, 03 Jul 2008 23:39:46 -0700 (PDT) Received: by 10.110.109.4 with HTTP; Thu, 3 Jul 2008 23:39:46 -0700 (PDT) Message-ID: Date: Fri, 04 Jul 2008 06:40:00 -0000 From: teawater To: "Michael Snyder" Subject: Re: [patch]: Fix memory leak of target-descriptions.c Cc: gdb@sourceware.org In-Reply-To: <1215126917.3549.74.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1215126917.3549.74.camel@localhost.localdomain> X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-07/txt/msg00030.txt.bz2 Michael, Thank you very much. teawater On Fri, Jul 4, 2008 at 07:15, Michael Snyder wrote: > On Mon, 2008-06-30 at 16:58 +0800, teawater wrote: >> target-descriptions.c has a memory leek in function >> maint_print_c_tdesc_cmd. char *function is xmalloc at line 1016. >> There are returns at the end of this function without calling free. >> And this variable is just used in this function. So I change it to >> "alloca". >> This patch is for the GDB cvs version. >> >> 2008-06-21 Hui Zhu >> * target-descriptions.c (maint_print_c_tdesc_cmd): Fix a memory leak. >> >> --- a/gdb/target-descriptions.c >> +++ b/gdb/target-descriptions.c >> @@ -1013,7 +1013,7 @@ maint_print_c_tdesc_cmd (char *args, int >> error (_("The current target description did not come from an XML file.")); >> >> filename = lbasename (target_description_filename); >> - function = xmalloc (strlen (filename) + 1); >> + function = alloca (strlen (filename) + 1); >> for (inp = filename, outp = function; *inp != '\0'; inp++) >> if (*inp == '.') >> break; > > This looks right to me -- committed. > > > >