This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] valops.c (find_oload_champ): Free malloced pointer.
- From: Joel Brobecker <brobecker at adacore dot com>
- To: Michael Snyder <msnyder at vmware dot com>
- Cc: "gdb-patches at sourceware dot org" <gdb-patches at sourceware dot org>
- Date: Mon, 7 Mar 2011 15:07:07 +0400
- Subject: Re: [RFA] valops.c (find_oload_champ): Free malloced pointer.
- References: <4D7196B6.1030102@vmware.com>
> 2011-03-04 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
>
> * valops.c (find_oload_champ): Free malloced pointer.
I don't think that this is correct. The code sets *oload_champ_bv
to bv in certain cases. If you xfree bv, you'll be returning a dangling
pointer.
It does look like there is a genuine memory leak however. The correct
fix is to xfree bv only if oload_champ_bv wasn't set to bv, though.
An easier-to-program-but-less-optimal solution could be to store
a duplicate of bv in oload_champ_bv and xfree bv at the end. Not too
fond of this, but I'm not sure the extra code to know whether or not
to xfree bv is going to be too elegant either...
--
Joel