diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-02-14 06:54:46 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-02-14 06:54:46 +0000 |
commit | 7b8290f7e53e1b9f5521dd284e78ad488a12f0d0 (patch) | |
tree | 0bd2688b9eeb7badda23c05a6040b55dc68cdf92 | |
parent | df33a35f6010fea92c786c0d8f85bfd7c73ebd3e (diff) |
Fix use-after-free introduced by me being an idiot.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150461 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/libclang/CIndexDiagnostic.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/libclang/CIndexDiagnostic.cpp b/tools/libclang/CIndexDiagnostic.cpp index a36ca8c5d3..6a2a2b1904 100644 --- a/tools/libclang/CIndexDiagnostic.cpp +++ b/tools/libclang/CIndexDiagnostic.cpp @@ -44,16 +44,14 @@ CXDiagnosticImpl::~CXDiagnosticImpl() {} namespace { class CXDiagnosticCustomNoteImpl : public CXDiagnosticImpl { - CXString Message; + std::string Message; CXSourceLocation Loc; public: CXDiagnosticCustomNoteImpl(StringRef Msg, CXSourceLocation L) : CXDiagnosticImpl(CustomNoteDiagnosticKind), - Message(createCXString(Msg)), Loc(L) {} + Message(Msg), Loc(L) {} - virtual ~CXDiagnosticCustomNoteImpl() { - clang_disposeString(Message); - } + virtual ~CXDiagnosticCustomNoteImpl() {} CXDiagnosticSeverity getSeverity() const { return CXDiagnostic_Note; @@ -64,7 +62,7 @@ public: } CXString getSpelling() const { - return Message; + return createCXString(StringRef(Message), false); } CXString getDiagnosticOption(CXString *Disable) const { |