[cfe-commits] r84601 - /cfe/trunk/lib/Rewrite/RewriteRope.cpp

Ted Kremenek kremenek at apple.com
Mon Oct 19 22:25:12 PDT 2009


Author: kremenek
Date: Tue Oct 20 00:25:11 2009
New Revision: 84601

URL: http://llvm.org/viewvc/llvm-project?rev=84601&view=rev
Log:
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).

Modified:
    cfe/trunk/lib/Rewrite/RewriteRope.cpp

Modified: cfe/trunk/lib/Rewrite/RewriteRope.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/RewriteRope.cpp?rev=84601&r1=84600&r2=84601&view=diff

==============================================================================
--- cfe/trunk/lib/Rewrite/RewriteRope.cpp (original)
+++ cfe/trunk/lib/Rewrite/RewriteRope.cpp Tue Oct 20 00:25:11 2009
@@ -798,9 +798,8 @@
   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);
 }
 





More information about the cfe-commits mailing list