From 4fdc1f8e2d51fc1932e291d66fca40d3a2d65978 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 24 Aug 2009 04:43:38 +0000 Subject: [PATCH] Correctly account for the Spaces array nul terminator. Thanks Chris! llvm-svn: 79894 --- lib/Support/raw_ostream.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Support/raw_ostream.cpp b/lib/Support/raw_ostream.cpp index 64d920503dc..230d9a81340 100644 --- a/lib/Support/raw_ostream.cpp +++ b/lib/Support/raw_ostream.cpp @@ -304,11 +304,12 @@ raw_ostream &raw_ostream::indent(unsigned NumSpaces) { " "; // Usually the indentation is small, handle it with a fastpath. - if (NumSpaces <= array_lengthof(Spaces)) + if (NumSpaces < array_lengthof(Spaces)) return write(Spaces, NumSpaces); while (NumSpaces) { - unsigned NumToWrite = std::min(NumSpaces, (unsigned)array_lengthof(Spaces)); + unsigned NumToWrite = std::min(NumSpaces, + (unsigned)array_lengthof(Spaces)-1); write(Spaces, NumToWrite); NumSpaces -= NumToWrite; }