r208481 - Don't leak default arg tokens on invalid destructors or conversion functions.

Richard Smith richard at metafoo.co.uk
Sat May 10 17:15:45 PDT 2014


On 10 May 2014 17:03, "Nico Weber" <thakis at chromium.org> wrote:
>
> On Sat, May 10, 2014 at 4:12 PM, Richard Smith <richard at metafoo.co.uk>
wrote:
>>
>>
>> On 10 May 2014 12:32, "Nico Weber" <nicolasweber at gmx.de> wrote:
>> >
>> > Author: nico
>> > Date: Sat May 10 14:23:28 2014
>> > New Revision: 208481
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=208481&view=rev
>> > Log:
>> > Don't leak default arg tokens on invalid destructors or conversion
functions.
>> >
>> > Fixes PR19689, and possibly the last leak in clang (PR19521). PR19689
contains
>> > a few suggestions on how to make the default argument token code a bit
more
>> > solid, these changes can possibly be landed in follow-ups.
>> >
>> > Modified:
>> >     cfe/trunk/include/clang/Sema/DeclSpec.h
>> >
>> > Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
>> > URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=208481&r1=208480&r2=208481&view=diff
>> >
==============================================================================
>> > --- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
>> > +++ cfe/trunk/include/clang/Sema/DeclSpec.h Sat May 10 14:23:28 2014
>> > @@ -1231,6 +1231,10 @@ struct DeclaratorChunk {
>> >      ///
>> >      /// This is used in various places for error recovery.
>> >      void freeParams() {
>> > +      if (Params) {
>> > +        delete Params->DefaultArgTokens;
>> > +        Params->DefaultArgTokens = nullptr;
>>
>> Doesn't Params point to an array? Looks like this will still leak the
second and subsequent default arguments.
>
> I believe it points to a CachedTokens, which is a typedef for
a SmallVector<Token, 4> – so I think it might be correct as-is?

You're only deleting the tokens for the first parameter

>> > +      }
>> >        if (DeleteParams) {
>> >          delete[] Params;
>> >          DeleteParams = false;
>> >
>> >
>> > _______________________________________________
>> > cfe-commits mailing list
>> > cfe-commits at cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140510/331c00d0/attachment.html>


More information about the cfe-commits mailing list