From: Chris Lattner Date: Fri, 23 May 2008 23:29:33 +0000 (+0000) Subject: fix a nasty off-by-one error. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=514b24cb534d00fbfa431bdd6fc46def546fe228;p=clang fix a nasty off-by-one error. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51519 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp index 9d5d7a7410..f1fd3f7ba9 100644 --- a/lib/Rewrite/RewriteRope.cpp +++ b/lib/Rewrite/RewriteRope.cpp @@ -578,7 +578,7 @@ void RopePieceBTreeInterior::erase(unsigned Offset, unsigned NumBytes) { NumBytes -= CurChild->size(); CurChild->Destroy(); --NumChildren; - if (i+1 != getNumChildren()) + if (i != getNumChildren()) memmove(&Children[i], &Children[i+1], (getNumChildren()-i)*sizeof(Children[0])); } diff --git a/test/Rewriter/crash.m b/test/Rewriter/crash.m new file mode 100644 index 0000000000..59f18f37c2 --- /dev/null +++ b/test/Rewriter/crash.m @@ -0,0 +1,14 @@ +// RUN: clang -rewrite-objc -o - %s +// rdar://5950938 +@interface NSArray {} ++ (id)arrayWithObjects:(id)firstObj, ...; +@end + +@interface NSConstantString {} +@end + +int main() { + id foo = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", 0]; + return 0; +} +