This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: RFA free(NULL) in bcache.c
- To: "Philippe De Muyter" <phdm at macqel dot be>
- Subject: Re: RFA free(NULL) in bcache.c
- From: Jim Blandy <jimb at zwingli dot cygnus dot com>
- Date: 18 Apr 2000 13:46:31 -0500
- Cc: gdb-patches at sourceware dot cygnus dot com (gdb-patches at sourceware dot cygnus dot com)
- References: <200004120905.LAA10853@mail.macqel.be>
Yes, please do. Thanks.
> I recently have had a core dump there, and the other instance of
> `free (bcache->bucket)' in bache.c is protected against `free (NULL)', so
> I think this is safe. OK to commit ?
>
> Philippe De Muyter <phdm@macqel.be>
>
> * bcache.c (free_bcache): Do not free NULL.
>
> Index: gdb/bcache.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/bcache.c,v
> retrieving revision 1.2
> diff -u -p -r1.2 bcache.c
> --- bcache.c 2000/02/08 04:39:01 1.2
> +++ bcache.c 2000/04/12 08:52:26
> @@ -189,7 +189,8 @@ void
> free_bcache (struct bcache *bcache)
> {
> obstack_free (&bcache->cache, 0);
> - free (bcache->bucket);
> + if (bcache->bucket)
> + free (bcache->bucket);
>
> /* This isn't necessary, but at least the bcache is always in a
> consistent state. */
>