[clang] f4de606 - fix use-after-free introduced in 8b76b44e46ac
Augie Fackler via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 2 11:38:16 PDT 2023
Author: Augie Fackler
Date: 2023-08-02T14:38:08-04:00
New Revision: f4de606ef271fe362f03d30c53a850f9877ec238
URL: https://github.com/llvm/llvm-project/commit/f4de606ef271fe362f03d30c53a850f9877ec238
DIFF: https://github.com/llvm/llvm-project/commit/f4de606ef271fe362f03d30c53a850f9877ec238.diff
LOG: fix use-after-free introduced in 8b76b44e46ac
ASan catches this easily enough.
Added:
Modified:
clang/lib/ExtractAPI/DeclarationFragments.cpp
Removed:
################################################################################
diff --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index ea72835c995313..375bdfbb02fbfd 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -606,7 +606,7 @@ DeclarationFragments
DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(
const CXXMethodDecl *Method) {
DeclarationFragments Fragments;
- StringRef Name;
+ std::string Name;
if (isa<CXXConstructorDecl>(Method)) {
auto *Constructor = dyn_cast<CXXConstructorDecl>(Method);
Name = cast<CXXRecordDecl>(Constructor->getDeclContext())->getName();
@@ -614,7 +614,7 @@ DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(
Fragments.append("explicit", DeclarationFragments::FragmentKind::Keyword)
.appendSpace();
} else if (isa<CXXDestructorDecl>(Method))
- Name = StringRef(Method->getNameAsString());
+ Name = Method->getNameAsString();
DeclarationFragments After;
Fragments.append(Name, DeclarationFragments::FragmentKind::Identifier)
More information about the cfe-commits
mailing list