From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14144 invoked by alias); 30 Jun 2008 08:58:59 -0000 Received: (qmail 14134 invoked by uid 22791); 30 Jun 2008 08:58:58 -0000 X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.184) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 30 Jun 2008 08:58:41 +0000 Received: by ti-out-0910.google.com with SMTP id d10so686522tib.12 for ; Mon, 30 Jun 2008 01:58:38 -0700 (PDT) Received: by 10.110.46.3 with SMTP id t3mr4283653tit.33.1214816318569; Mon, 30 Jun 2008 01:58:38 -0700 (PDT) Received: by 10.110.109.4 with HTTP; Mon, 30 Jun 2008 01:58:38 -0700 (PDT) Message-ID: Date: Mon, 30 Jun 2008 08:58:00 -0000 From: teawater To: gdb@sourceware.org Subject: [patch]: Fix memory leak of target-descriptions.c MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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-06/txt/msg00313.txt.bz2 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;