From d1c82fe726a8776cb965c5bf1f6f6c0d311ef6bc Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Tue, 15 Jun 2010 19:20:28 +0000 Subject: fpcmp: Fix a possible infinite loop when comparing something like: 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 | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/Support/FileUtilities.cpp') diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 095395f122..11c1e02aba 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -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; -- cgit v1.2.3-18-g5258