APFloat::toString(): Fix overrun at scanning.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 19 Feb 2012 03:18:29 +0000 (03:18 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 19 Feb 2012 03:18:29 +0000 (03:18 +0000)
FYI, clang/test/SemaTemplate/template-id-printing.cpp had been failing due to it on cygwin-clang.

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

lib/Support/APFloat.cpp

index 8913dd6def56dbe252d2af2cc154ac643c6020ab..525aea28c676fd407c9ca84d8afea960913ebf8f 100644 (file)
@@ -3340,7 +3340,7 @@ namespace {
     // Rounding down is just a truncation, except we also want to drop
     // trailing zeros from the new result.
     if (buffer[FirstSignificant - 1] < '5') {
-      while (buffer[FirstSignificant] == '0')
+      while (FirstSignificant < N && buffer[FirstSignificant] == '0')
         FirstSignificant++;
 
       exp += FirstSignificant;