]> granicus.if.org Git - clang/commitdiff
Fix a reference count imbalance in RewriteRope::MakeRopeString().
authorTed Kremenek <kremenek@apple.com>
Tue, 20 Oct 2009 05:25:11 +0000 (05:25 +0000)
committerTed Kremenek <kremenek@apple.com>
Tue, 20 Oct 2009 05:25:11 +0000 (05:25 +0000)
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

lib/Rewrite/RewriteRope.cpp

index 30bbcfafb5321e8cedeb48a44e0c7e69cd0c03f8..bd99732dc872cbc0b3308fff07c4e12d8a3e6c96 100644 (file)
@@ -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);
 }