From: Chris Lattner Date: Sun, 26 Oct 2008 19:20:47 +0000 (+0000) Subject: fix PR2953, an off-by-one error handling formatted i/o. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f61ca1eeda9cf2427047d83febe6fac1fbb1e84e;p=oota-llvm.git fix PR2953, an off-by-one error handling formatted i/o. 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 --- diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index a4c293660b0..8c704cb4714 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -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.