[PATCH] D150254: [tidy] Fix possible use-after-free in IdentifierNamingCheck
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 10 03:36:47 PDT 2023
kadircet added a comment.
In D150254#4331738 <https://reviews.llvm.org/D150254#4331738>, @njames93 wrote:
> In D150254#4331640 <https://reviews.llvm.org/D150254#4331640>, @kadircet wrote:
>
>> see https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidy.cpp#L638 for such a pattern, clangd also initializes checks with a similar approach.
>
> In this example the factory outlives the check so there is no possible use after free.
Sorry you're right, I thought checks created in https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clang-tidy/ClangTidy.cpp#L660 would become part of the return value, but instead they're dropped on the floor.
but nevertheless, clangd has this pattern in https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/clangd/ParsedAST.cpp#L479. I am happy to change the pattern in clangd as well, but I don't think there's anything requiring users to keep the "factory" around in the contract.
> In regard to this change, I think that this member can actually be removed entirely as we can get the name of the check using the `getID` virtual function.
made it protected and used it instead.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150254/new/
https://reviews.llvm.org/D150254
More information about the cfe-commits
mailing list