fpcmp: Fix a possible infinite loop when comparing something like:
authorDaniel Dunbar <daniel@zuster.org>
Tue, 15 Jun 2010 19:20:28 +0000 (19:20 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 15 Jun 2010 19:20:28 +0000 (19:20 +0000)
  1..19 ok
to
  1..20 o k
(yes, the odd space is necessary).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106032 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/FileUtilities.cpp

index 095395f122312ecc483eb170459a1cb94e1e9d98..11c1e02ababb0723a8d07ecd2098aac42d1b1195 100644 (file)
@@ -51,7 +51,15 @@ static const char *BackupNumber(const char *Pos, const char *FirstChar) {
   if (!isNumberChar(*Pos)) return Pos;
 
   // Otherwise, return to the start of the number.
+  bool HasPeriod = false;
   while (Pos > FirstChar && isNumberChar(Pos[-1])) {
+    // Backup over at most one period.
+    if (Pos[-1] == '.') {
+      if (HasPeriod)
+        break;
+      HasPeriod = true;
+    }
+
     --Pos;
     if (Pos > FirstChar && isSignedChar(Pos[0]) && !isExponentChar(Pos[-1]))
       break;