Fix undefined behavior (signed integer overflow) when Clang parses a hexfloat with...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 24 Aug 2012 00:01:19 +0000 (00:01 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Fri, 24 Aug 2012 00:01:19 +0000 (00:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162505 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APFloat.cpp

index ed261a4194c9134e4357c11353280c7ff359e980..f143e6d0adeb353e157fbe6084d716709c4c1916 100644 (file)
@@ -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)