From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27741 invoked by alias); 3 Jul 2008 23:15:39 -0000 Received: (qmail 27733 invoked by uid 22791); 3 Jul 2008 23:15:39 -0000 X-Spam-Check-By: sourceware.org Received: from bluesmobile.specifix.com (HELO bluesmobile.specifix.com) (216.129.118.140) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 03 Jul 2008 23:15:18 +0000 Received: from [127.0.0.1] (bluesmobile.specifix.com [216.129.118.140]) by bluesmobile.specifix.com (Postfix) with ESMTP id 4C7133C027; Thu, 3 Jul 2008 16:15:17 -0700 (PDT) Subject: Re: [patch]: Fix memory leak of target-descriptions.c From: Michael Snyder To: teawater Cc: gdb@sourceware.org In-Reply-To: References: Content-Type: text/plain Date: Thu, 03 Jul 2008 23:15:00 -0000 Message-Id: <1215126917.3549.74.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.10.3 (2.10.3-7.fc7) Content-Transfer-Encoding: 7bit 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/msg00027.txt.bz2 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.