fix PR2953, an off-by-one error handling formatted i/o.
authorChris Lattner <sabre@nondot.org>
Sun, 26 Oct 2008 19:20:47 +0000 (19:20 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 Oct 2008 19:20:47 +0000 (19:20 +0000)
Thanks to Török Edwin for the awesome reduced testcase.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58199 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/raw_ostream.cpp

index a4c293660b0b37889357e194e05d6456451ddd30..8c704cb47146c551294bd8281a525a2fba5cbf30 100644 (file)
@@ -175,7 +175,7 @@ raw_ostream &raw_ostream::operator<<(const format_object_base &Fmt) {
     unsigned BytesUsed = Fmt.print(&V[0], NextBufferSize);
     
     // If BytesUsed fit into the vector, we win.
-    if (BytesUsed < NextBufferSize)
+    if (BytesUsed <= NextBufferSize)
       return write(&V[0], BytesUsed);
     
     // Otherwise, try again with a new size.