From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27507 invoked by alias); 31 Mar 2010 21:20:32 -0000 Received: (qmail 27490 invoked by uid 22791); 31 Mar 2010 21:20:31 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,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; Wed, 31 Mar 2010 21:20:22 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2VLEke1032543 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Mar 2010 17:14:46 -0400 Received: from psique.localnet (vpn-235-205.phx2.redhat.com [10.3.235.205]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2VLEkag027389; Wed, 31 Mar 2010 17:14:46 -0400 From: Sergio Durigan Junior To: Pedro Alves Subject: Re: Fix for PR 10736 Date: Wed, 31 Mar 2010 21:20:00 -0000 User-Agent: KMail/1.13.1 (Linux/2.6.32.9-70.fc12.x86_64; KDE/4.4.1; x86_64; ; ) Cc: gdb-patches@sourceware.org References: <201003292101.48377.sergiodj@redhat.com> <201003301144.25720.pedro@codesourcery.com> In-Reply-To: <201003301144.25720.pedro@codesourcery.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201003311814.43957.sergiodj@redhat.com> 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: 2010-03/txt/msg01120.txt.bz2 Hi Pedro, On Tuesday 30 March 2010 07:44:25, Pedro Alves wrote: > > + /* Should we re-read the XML info for this target? */ > > + if (my_gdb_datadir && strcmp (my_gdb_datadir, gdb_datadir) != 0) > > + { > > + /* The data-directory changed from the last time we used it. > > + It means that we have to re-read the XML info. */ > > + have_initialized_sysinfo = 0; > > + xfree (my_gdb_datadir); > > + my_gdb_datadir = NULL; > > The previous data dir is only released if the datadir changed. > > > + if (sysinfo) > > + free_syscalls_info ((void *) sysinfo); > > + } > > > > + > > + /* Saving the data-directory used to read this XML info. */ > > + my_gdb_datadir = xstrdup (gdb_datadir); > > So here my_gdb_datadir leaks if the datadir _doesn't_ change. > I think you just need to move the xfree and my_data_dir=NULL > statements outside the `if', before the early return. Sorry, I don't know if I understood. If the datadir doesn't change, the call to xstrdup will only be made once (i.e., when `have_initialized_sysinfo' is zero). After that, it will never be called again unless datadir changes. Thanks, -- Sergio Durigan Junior Debugger Engineer Red Hat Inc.