diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-07-01 23:54:08 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-07-01 23:54:08 +0000 |
commit | 228156c04fb34fb702d2a4d8d2e954ae59540ca0 (patch) | |
tree | e6a16b35ba0d1658410ed7f679685f7c276373b5 /llvm/lib/Support/APFloat.cpp | |
parent | 0e6e4aa5db6202a72059819c5cf69c90a9828bfa (diff) | |
download | bcm5719-llvm-228156c04fb34fb702d2a4d8d2e954ae59540ca0.tar.gz bcm5719-llvm-228156c04fb34fb702d2a4d8d2e954ae59540ca0.zip |
[APFloat] Ensure that we can properly parse strings that do not have null terminators.
rdar://14323230
llvm-svn: 185397
Diffstat (limited to 'llvm/lib/Support/APFloat.cpp')
-rw-r--r-- | llvm/lib/Support/APFloat.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp index a7ff9f68cf7..ae4a101feba 100644 --- a/llvm/lib/Support/APFloat.cpp +++ b/llvm/lib/Support/APFloat.cpp @@ -2481,7 +2481,14 @@ APFloat::convertFromDecimalString(StringRef str, roundingMode rounding_mode) 42039/12655 < L < 28738/8651 [ numerator <= 65536 ] */ - if (decDigitValue(*D.firstSigDigit) >= 10U) { + // Test if we have a zero number allowing for strings with no null terminators + // and zero decimals with non-zero exponents. + // + // We computed firstSigDigit by ignoring all zeros and dots. Thus if + // D->firstSigDigit equals str.end(), every digit must be a zero and there can + // be at most one dot. On the other hand, if we have a zero with a non-zero + // exponent, then we know that D.firstSigDigit will be non-numeric. + if (decDigitValue(*D.firstSigDigit) >= 10U || D.firstSigDigit == str.end()) { category = fcZero; fs = opOK; |