[cfe-commits] r49259 - /cfe/trunk/include/clang/Rewrite/RewriteRope.h

Chris Lattner sabre at nondot.org
Sat Apr 5 21:36:15 PDT 2008


Author: lattner
Date: Sat Apr  5 23:36:15 2008
New Revision: 49259

URL: http://llvm.org/viewvc/llvm-project?rev=49259&view=rev
Log:
don't dereference hte end iterator when inserting at end of buffer.
Patch by Cédric Venet!

Modified:
    cfe/trunk/include/clang/Rewrite/RewriteRope.h

Modified: cfe/trunk/include/clang/Rewrite/RewriteRope.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/RewriteRope.h?rev=49259&r1=49258&r2=49259&view=diff

==============================================================================
--- cfe/trunk/include/clang/Rewrite/RewriteRope.h (original)
+++ cfe/trunk/include/clang/Rewrite/RewriteRope.h Sat Apr  5 23:36:15 2008
@@ -148,6 +148,7 @@
   
   iterator getAtOffset(unsigned Offset) {
     assert(Offset <= CurSize && "Offset out of range!");
+    if (Offset == CurSize) return iterator(Chunks.end(), 0);
     std::list<RopePiece>::iterator Piece = Chunks.begin();
     while (Offset >= Piece->size()) {
       Offset -= Piece->size();
@@ -158,6 +159,7 @@
 
   const_iterator getAtOffset(unsigned Offset) const {
     assert(Offset <= CurSize && "Offset out of range!");
+    if (Offset == CurSize) return const_iterator(Chunks.end(), 0);
     std::list<RopePiece>::const_iterator Piece = Chunks.begin();
     while (Offset >= Piece->size()) {
       Offset -= Piece->size();





More information about the cfe-commits mailing list