From 2726ba629a64234000dd95679561910685a59632 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 23 Apr 2014 21:41:51 +0000 Subject: [PATCH] Fix leak introduced in r194610, found by LSan. LSan folks: LSan pointed to #0 0x4953e0 in operator new[](unsigned long) llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:64 #1 0x7fb82af5372f in clang::RewriteRope::MakeRopeString(char const*, char const*) llvm/tools/clang/lib/Rewrite/Core/RewriteRope.cpp:796 instead of to the actual leak, which made tracking this down slower than it could have been. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207031 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Index/CommentToXML.h | 1 + lib/Index/CommentToXML.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/include/clang/Index/CommentToXML.h b/include/clang/Index/CommentToXML.h index 8444b14534..c68d7a47d5 100644 --- a/include/clang/Index/CommentToXML.h +++ b/include/clang/Index/CommentToXML.h @@ -29,6 +29,7 @@ class CommentToXMLConverter { public: CommentToXMLConverter() : FormatContext(0), FormatInMemoryUniqueId(0) {} + ~CommentToXMLConverter(); void convertCommentToHTML(const comments::FullComment *FC, SmallVectorImpl &HTML, diff --git a/lib/Index/CommentToXML.cpp b/lib/Index/CommentToXML.cpp index 4f5c0745d7..54087bd87d 100644 --- a/lib/Index/CommentToXML.cpp +++ b/lib/Index/CommentToXML.cpp @@ -1136,6 +1136,10 @@ void CommentASTToXMLConverter::appendToResultWithCDATAEscaping(StringRef S) { Result << "]]>"; } +CommentToXMLConverter::~CommentToXMLConverter() { + delete FormatContext; +} + void CommentToXMLConverter::convertCommentToHTML(const FullComment *FC, SmallVectorImpl &HTML, const ASTContext &Context) { -- 2.40.0