diff options
author | John McCall <rjmccall@apple.com> | 2010-03-01 18:38:45 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-03-01 18:38:45 +0000 |
commit | d44c6cc4776d38dcb91069a776904b307f634370 (patch) | |
tree | ded4a5273a80496ec0d3a3bbad758eac8dadd461 /lib/Support/APFloat.cpp | |
parent | 81607c902f1b8c077834004260c1c3880f54a443 (diff) |
Don't potentially read past the end of the fill data when making a NaN from
an APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APFloat.cpp')
-rw-r--r-- | lib/Support/APFloat.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp index 16a0c23292..619f061862 100644 --- a/lib/Support/APFloat.cpp +++ b/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; |