forked from OSchip/llvm-project
fix a rewriter crash on zero length files.
llvm-svn: 50126
This commit is contained in:
parent
2161d6c075
commit
68a27fac9d
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue