From c6dbe30e8831722e0ebf44345414275e723fa01a Mon Sep 17 00:00:00 2001 From: John McCall Date: Mon, 1 Mar 2010 18:38:45 +0000 Subject: Don't potentially read past the end of the fill data when making a NaN from an APInt. llvm-svn: 97467 --- llvm/lib/Support/APFloat.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Support') diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index 16a0c232927..619f061862c 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -638,7 +638,8 @@ void APFloat::makeNaN(bool SNaN, bool Negative, const APInt *fill) 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; -- cgit v1.2.3