summaryrefslogtreecommitdiff
path: root/lib/Support/APFloat.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 00:01:19 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-08-24 00:01:19 +0000
commitb080e2fb1c8164c95e6f8d06754f0c7637eeae7b (patch)
tree145515903474dbdde6c1f4aa3147850b0031e7a2 /lib/Support/APFloat.cpp
parent5d04a3ad0e202a50122d6739c9af533575254a80 (diff)
downloadllvm-b080e2fb1c8164c95e6f8d06754f0c7637eeae7b.tar.gz
llvm-b080e2fb1c8164c95e6f8d06754f0c7637eeae7b.tar.bz2
llvm-b080e2fb1c8164c95e6f8d06754f0c7637eeae7b.tar.xz
Fix undefined behavior (signed integer overflow) when Clang parses a hexfloat with an enormous exponent. Caught by an existing unit test + -ftrapv.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162505 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APFloat.cpp')
-rw-r--r--lib/Support/APFloat.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Support/APFloat.cpp b/lib/Support/APFloat.cpp
index ed261a4194..f143e6d0ad 100644
--- a/lib/Support/APFloat.cpp
+++ b/lib/Support/APFloat.cpp
@@ -196,8 +196,10 @@ totalExponent(StringRef::iterator p, StringRef::iterator end,
assert(value < 10U && "Invalid character in exponent");
unsignedExponent = unsignedExponent * 10 + value;
- if (unsignedExponent > 32767)
+ if (unsignedExponent > 32767) {
overflow = true;
+ break;
+ }
}
if (exponentAdjustment > 32767 || exponentAdjustment < -32768)