[llvm-commits] [llvm] r97467 - /llvm/trunk/lib/Support/APFloat.cpp

John McCall rjmccall at apple.com
Mon Mar 1 10:38:46 PST 2010


Author: rjmccall
Date: Mon Mar  1 12:38:45 2010
New Revision: 97467

URL: http://llvm.org/viewvc/llvm-project?rev=97467&view=rev
Log:
Don't potentially read past the end of the fill data when making a NaN from
an APInt.


Modified:
    llvm/trunk/lib/Support/APFloat.cpp

Modified: llvm/trunk/lib/Support/APFloat.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=97467&r1=97466&r2=97467&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APFloat.cpp (original)
+++ llvm/trunk/lib/Support/APFloat.cpp Mon Mar  1 12:38:45 2010
@@ -638,7 +638,8 @@
   if (!fill || fill->getNumWords() < numParts)
     APInt::tcSet(significand, 0, numParts);
   if (fill) {
-    APInt::tcAssign(significand, fill->getRawData(), partCount());
+    APInt::tcAssign(significand, fill->getRawData(),
+                    std::min(fill->getNumWords(), numParts));
 
     // Zero out the excess bits of the significand.
     unsigned bitsToPreserve = semantics->precision - 1;





More information about the llvm-commits mailing list