Unreviewed changes
2 is the latest approved patch-set.
The change was submitted with unreviewed changes in the following files:
```
The name of the file: xfa/fgas/crt/cfgas_stringformatter.cpp
Insertions: 12, Deletions: 12.
@@ -1359,18 +1359,18 @@
ccf--;
break;
case 'E': {
- pdfium::CheckedNumeric<int32_t> safeExponent = 0;
- bool bExpSign = false;
- pdfium::CheckedNumeric<int32_t> safeMultiplier = 1;
+ bool has_exp_sign = false;
+ pdfium::CheckedNumeric<int32_t> safe_exponent = 0;
+ pdfium::CheckedNumeric<int32_t> safe_multiplier = 1;
while (cc < spSrcNum.size()) {
if (spSrcNum[cc] == 'E' || spSrcNum[cc] == 'e') {
break;
}
if (FXSYS_IsDecimalDigit(spSrcNum[cc])) {
int32_t digit = FXSYS_DecimalCharToInt(spSrcNum[cc]);
- safeExponent += safeMultiplier * digit;
- safeMultiplier *= 10;
- if (!safeExponent.IsValid() || !safeMultiplier.IsValid()) {
+ safe_exponent += safe_multiplier * digit;
+ safe_multiplier *= 10;
+ if (!safe_exponent.IsValid() || !safe_multiplier.IsValid()) {
return false;
}
cc--;
@@ -1383,7 +1383,7 @@
if (cc - iMinusLen + 1 <= spSrcNum.size() &&
UNSAFE_TODO(wcsncmp(spSrcNum.data() + (cc - iMinusLen + 1),
wsMinus.c_str(), iMinusLen)) == 0) {
- bExpSign = true;
+ has_exp_sign = true;
cc -= iMinusLen;
continue;
}
@@ -1391,8 +1391,8 @@
return false;
}
cc--;
- iExponent = safeExponent.ValueOrDie();
- iExponent = bExpSign ? -iExponent : iExponent;
+ iExponent = safe_exponent.ValueOrDie();
+ iExponent = has_exp_sign ? -iExponent : iExponent;
ccf--;
break;
}
@@ -1565,13 +1565,13 @@
return false;
}
iExponent = 0;
- bool bExpSign = false;
+ bool has_exp_sign = false;
cc++;
if (cc < spSrcNum.size()) {
if (spSrcNum[cc] == '+') {
cc++;
} else if (spSrcNum[cc] == '-') {
- bExpSign = true;
+ has_exp_sign = true;
cc++;
}
}
@@ -1586,7 +1586,7 @@
iExponent = iExponent * 10 + digit;
cc++;
}
- iExponent = bExpSign ? -iExponent : iExponent;
+ iExponent = has_exp_sign ? -iExponent : iExponent;
break;
}
case '$': {
```
Change information
Commit message:
Fix exponent parsing in CFGAS_StringFormatter::ParseNum backward loop
When parsing numbers without a dot in the input but with an exponent
specified (e.g., "12e2"), the parser walks backward. The backward loop
incorrectly calculated the exponent by multiplying the current
accumulator by 10 and adding the new digit, which is incorrect for
decimal base when walking backward.
Fix this by using CheckedNumeric and a multiplier that increases by
factor of 10 at each step, ensuring correct positional value of digits
when processed from right to left.
Add unit tests to verify the fix for both positive and negative
exponents.
TAG=agy
CONV=32392532-2550-4531-8902-0f605362e1ca
Change-Id: If0cd346150150952cff1c40832c316f047aa9839
Files:
- M xfa/fgas/crt/cfgas_stringformatter.cpp
- M xfa/fgas/crt/cfgas_stringformatter_unittest.cpp
Change size: S
Delta: 2 files changed, 15 insertions(+), 11 deletions(-)
Branch: refs/heads/main
Submit Requirements:
Code-Review: +1 by Lei Zhang