This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] c-common.c: Fix memory leak.
- From: Jeffrey A Law <law at redhat dot com>
- To: Kazu Hirata <kazu at cs dot umass dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 13 Dec 2004 09:34:28 -0700
- Subject: Re: [patch] c-common.c: Fix memory leak.
- Organization: Red Hat, Inc
- References: <20041211.103042.102022266.kazu@cs.umass.edu>
- Reply-to: law at redhat dot com
On Sat, 2004-12-11 at 10:30 -0500, Kazu Hirata wrote:
> Hi,
>
> Attached is a patch to fix memory leak.
>
> Consider the "if" statement shown in the patch. If we are returning
> cstr.txt, nobody will ever reference namep, which is allocated via
> XVECNEW a few lines up.
>
> The patch solves this problem by freeing namep with XDELETEVEC.
>
> Tested on i686-pc-linux-gnu. OK to apply?
>
> Kazu Hirata
>
> 2004-12-10 Kazu Hirata <kazu@cs.umass.edu>
>
> * c-common.c (fname_as_string): Free namep if we are returning
> cstr.text.
Approved.
You might want to put fixing the macro names to be more consistent
on the longer term todo list.
jeff