[cfe-commits] r150461 - /cfe/trunk/tools/libclang/CIndexDiagnostic.cpp

Ted Kremenek kremenek at apple.com
Mon Feb 13 22:54:46 PST 2012


Author: kremenek
Date: Tue Feb 14 00:54:46 2012
New Revision: 150461

URL: http://llvm.org/viewvc/llvm-project?rev=150461&view=rev
Log:
Fix use-after-free introduced by me being an idiot.

Modified:
    cfe/trunk/tools/libclang/CIndexDiagnostic.cpp

Modified: cfe/trunk/tools/libclang/CIndexDiagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexDiagnostic.cpp?rev=150461&r1=150460&r2=150461&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexDiagnostic.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexDiagnostic.cpp Tue Feb 14 00:54:46 2012
@@ -44,16 +44,14 @@
 
 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 @@
   }
   
   CXString getSpelling() const {
-    return Message;
+    return createCXString(StringRef(Message), false);
   }
   
   CXString getDiagnosticOption(CXString *Disable) const {





More information about the cfe-commits mailing list