This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] cplus-demangler, free resource after a failed call to gnu_special.
- From: Andrew Burgess <aburgess at broadcom dot com>
- To: Ian Lance Taylor <iant at google dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Jason Merrill <jason at redhat dot com>, <gdb-patches at sourceware dot org>
- Date: Sat, 10 May 2014 20:13:54 +0100
- Subject: Re: [PATCH] cplus-demangler, free resource after a failed call to gnu_special.
- Authentication-results: sourceware.org; auth=none
- References: <1399646123-9960-1-git-send-email-aburgess at broadcom dot com> <CAKOQZ8zCbzpkwR_HkraUsNoDHEPt2pUXsQEk8kf_Mc43DGTHJw at mail dot gmail dot com>
On 09/05/2014 9:53 PM, Ian Lance Taylor wrote:
> On Fri, May 9, 2014 at 7:35 AM, Andrew Burgess <aburgess@broadcom.com> wrote:
>
>> if ((AUTO_DEMANGLING || GNU_DEMANGLING))
>> {
>> success = gnu_special (work, &mangled, &decl);
>> + if (!success)
>> + {
>> + delete_work_stuff (work);
>> + string_delete (&decl);
>> + }
>
> As far as I can see, decl may be uninitialized at this point. I don't
> think you can call string_delete. You need to ensure that decl is
> initialized somehow.
There's a call to string_init on decl about 10 lines above the
above diff, just outside of context, but it's unconditional, so
I figured that would be enough.
Also, if gnu_special returns false, and the call to
demangle_prefix returns false then we call (near the bottom of
internal_cplus_demangle) mop_up, which calls string_delete.
Given that decl is initialised once, assuming that the string is
only released using delete_string then the internal state will
have been reset back to NULL, so calling delete_string should
be safe again.
Could you let me know if this is enough, or give me more details
on where you think the problem is as I'm missing it :)
Thanks for taking a look at this.
Andrew