From: Ted Kremenek Date: Tue, 20 Oct 2009 05:25:11 +0000 (+0000) Subject: Fix a reference count imbalance in RewriteRope::MakeRopeString(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=01fbef61a30abf65be2790811dc7677925c46668;p=clang Fix a reference count imbalance in RewriteRope::MakeRopeString(). This was causing a ton of memory to be leaked when using HTML diagnostics with the static analyzer (on large files with many errors). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84601 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp index 30bbcfafb5..bd99732dc8 100644 --- a/lib/Rewrite/RewriteRope.cpp +++ b/lib/Rewrite/RewriteRope.cpp @@ -798,9 +798,8 @@ RopePiece RewriteRope::MakeRopeString(const char *Start, const char *End) { memcpy(AllocBuffer->Data, Start, Len); AllocOffs = Len; - // Start out the new allocation with a refcount of 1, since we have an - // internal reference to it. - AllocBuffer->addRef(); + // Return a RopePiece that wraps 'AllocBuffer'. The constructor of RopePiece + // will increment the reference count of AllocBuffer. return RopePiece(AllocBuffer, 0, Len); }