diff options
author | Nick Kledzik <kledzik@apple.com> | 2012-10-02 20:01:48 +0000 |
---|---|---|
committer | Nick Kledzik <kledzik@apple.com> | 2012-10-02 20:01:48 +0000 |
commit | 6e033d6dcd374634a64825692342c555d2eff38f (patch) | |
tree | 8f6d0d9b206b95dda3cc36ef0c965ff881e5b745 /lib/Support/StringRef.cpp | |
parent | fdb15850e6f2d395b128bde0f2fff6b20c96adc6 (diff) |
Improve overflow detection in StringRef::getAsUnsignedInteger().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/StringRef.cpp')
-rw-r--r-- | lib/Support/StringRef.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Support/StringRef.cpp b/lib/Support/StringRef.cpp index 8aab4b2760..f8e9208462 100644 --- a/lib/Support/StringRef.cpp +++ b/lib/Support/StringRef.cpp @@ -350,8 +350,8 @@ bool llvm::getAsUnsignedInteger(StringRef Str, unsigned Radix, unsigned long long PrevResult = Result; Result = Result*Radix+CharVal; - // Check for overflow. - if (Result < PrevResult) + // Check for overflow by shifting back and seeing if bits were lost. + if (Result/Radix < PrevResult) return true; Str = Str.substr(1); |