]> granicus.if.org Git - clang/commitdiff
fix a nasty off-by-one error.
authorChris Lattner <sabre@nondot.org>
Fri, 23 May 2008 23:29:33 +0000 (23:29 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 23 May 2008 23:29:33 +0000 (23:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51519 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Rewrite/RewriteRope.cpp
test/Rewriter/crash.m [new file with mode: 0644]

index 9d5d7a741053f468df7d3f74586602346a290f80..f1fd3f7ba9711e24ef5839773c646a003071744b 100644 (file)
@@ -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 (file)
index 0000000..59f18f3
--- /dev/null
@@ -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;
+}
+