don't dereference hte end iterator when inserting at end of buffer.

Patch by Cédric Venet!

llvm-svn: 49259
This commit is contained in:
Chris Lattner 2008-04-06 04:36:15 +00:00
parent 1e830c07a2
commit 53adca6610
1 changed files with 2 additions and 0 deletions

View File

@ -148,6 +148,7 @@ public:
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 @@ public:
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();