[clang-tools-extra] r213845 - [clang-tidy] Fix a heap use-after-free bug detected by asan.
Benjamin Kramer
benny.kra at gmail.com
Fri Jul 25 01:53:45 PDT 2014
On Thu, Jul 24, 2014 at 9:09 PM, Richard Smith <richard at metafoo.co.uk> wrote:
>
> On 24 Jul 2014 01:46, "Benjamin Kramer" <benny.kra at googlemail.com> wrote:
>>
>> Author: d0k
>> Date: Thu Jul 24 03:34:42 2014
>> New Revision: 213845
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=213845&view=rev
>> Log:
>> [clang-tidy] Fix a heap use-after-free bug detected by asan.
>>
>> Modified:
>> clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp
>>
>> Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp?rev=213845&r1=213844&r2=213845&view=diff
>>
>> ==============================================================================
>> --- clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp (original)
>> +++ clang-tools-extra/trunk/clang-tidy/misc/UnusedRAII.cpp Thu Jul 24
>> 03:34:42 2014
>> @@ -17,7 +17,7 @@ namespace clang {
>> namespace ast_matchers {
>> AST_MATCHER(CXXRecordDecl, hasUserDeclaredDestructor) {
>> // TODO: If the dtor is there but empty we don't want to warn either.
>> - return Node.hasUserDeclaredDestructor();
>> + return Node.hasDefinition() && Node.hasUserDeclaredDestructor();
>
> Did you mean to include this change?
No, this was lying around in my working copy and snuck in. However
it's a fix for a crash encountered when this matcher is called on a
class with no definition. Still have to add a test case for that.
- Ben
>
>> }
>> } // namespace ast_matchers
>>
>> @@ -73,9 +73,9 @@ void UnusedRAIICheck::check(const MatchF
>> // Otherwise just suggest adding a name. To find the place to insert
>> the name
>> // find the first TypeLoc in the children of E, which always points to
>> the
>> // written type.
>> - const auto *TL =
>> - selectFirst<TypeLoc>("t",
>> match(expr(hasDescendant(typeLoc().bind("t"))),
>> - *E, *Result.Context));
>> + auto Matches =
>> + match(expr(hasDescendant(typeLoc().bind("t"))), *E,
>> *Result.Context);
>> + const auto *TL = selectFirst<TypeLoc>("t", Matches);
>> D << FixItHint::CreateInsertion(
>> Lexer::getLocForEndOfToken(TL->getLocEnd(), 0,
>> *Result.SourceManager,
>> Result.Context->getLangOpts()),
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list