From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21364 invoked by alias); 27 Feb 2011 22:05:54 -0000 Received: (qmail 21355 invoked by uid 22791); 27 Feb 2011 22:05:53 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_RG,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 27 Feb 2011 22:05:48 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1RM5lYr013594 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sun, 27 Feb 2011 17:05:47 -0500 Received: from host1.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1RM5jdC032282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sun, 27 Feb 2011 17:05:47 -0500 Received: from host1.dyn.jankratochvil.net (localhost [127.0.0.1]) by host1.dyn.jankratochvil.net (8.14.4/8.14.4) with ESMTP id p1RM5jM4024726; Sun, 27 Feb 2011 23:05:45 +0100 Received: (from jkratoch@localhost) by host1.dyn.jankratochvil.net (8.14.4/8.14.4/Submit) id p1RM5i0V024725; Sun, 27 Feb 2011 23:05:44 +0100 Date: Sun, 27 Feb 2011 22:12:00 -0000 From: Jan Kratochvil To: Michael Snyder Cc: "gdb-patches@sourceware.org" Subject: Re: [rfa] add_symbol_file_command, avoid memory leak. Message-ID: <20110227220544.GA24546@host1.dyn.jankratochvil.net> References: <4D69AAFC.6030607@vmware.com> <20110227171301.GA16297@host1.dyn.jankratochvil.net> <4D6AB5A2.3030807@vmware.com> <20110227204206.GA11932@host1.dyn.jankratochvil.net> <4D6AC8B5.4030702@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D6AC8B5.4030702@vmware.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2011-02/txt/msg00855.txt.bz2 On Sun, 27 Feb 2011 22:57:09 +0100, Michael Snyder wrote: > @@ -2169,15 +2169,15 @@ add_symbol_file_command (char *args, int > size_t num_sect_opts = 0; > struct cleanup *my_cleanups = make_cleanup (null_cleanup, NULL); > > - num_sect_opts = 16; > - sect_opts = (struct sect_opt *) xmalloc (num_sect_opts > - * sizeof (struct sect_opt)); > - > dont_repeat (); > > if (args == NULL) > error (_("add-symbol-file takes a file name and an address")); > > + num_sect_opts = 16; > + sect_opts = (struct sect_opt *) xmalloc (num_sect_opts > + * sizeof (struct sect_opt)); > + > argv = gdb_buildargv (args); > make_cleanup_freeargv (argv); > > How about this? Yes, the fix is OK now. There could be also added some make_cleanup (xfree, sect_opts); as discussed before; but it may be a different patch. Thanks, Jan