fix a rewriter crash on zero length files.

llvm-svn: 50126
This commit is contained in:
Chris Lattner 2008-04-23 03:21:50 +00:00
parent 2161d6c075
commit 68a27fac9d
2 changed files with 3 additions and 1 deletions

View File

@ -204,7 +204,8 @@ public:
void assign(const char *Start, const char *End) {
clear();
Chunks.insert(0, MakeRopeString(Start, End));
if (Start != End)
Chunks.insert(0, MakeRopeString(Start, End));
}
void insert(unsigned Offset, const char *Start, const char *End) {

View File

@ -741,6 +741,7 @@ void RopePieceBTree::erase(unsigned Offset, unsigned NumBytes) {
/// allocation instead of doing tons of tiny allocations.
RopePiece RewriteRope::MakeRopeString(const char *Start, const char *End) {
unsigned Len = End-Start;
assert(Len && "Zero length RopePiece is invalid!");
// If we have space for this string in the current alloc buffer, use it.
if (AllocOffs+Len <= AllocChunkSize) {