summaryrefslogtreecommitdiff
path: root/xfa/fgas
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2017-09-05 15:33:18 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-06 13:53:19 +0000
commit81f9eeef041f2974274751d7508598049ae32db2 (patch)
tree00bdcdddc9d141e4929005a14372bde65c68ee81 /xfa/fgas
parent3ef61c73a97b31000a21e323e04ad5397e517c4c (diff)
downloadpdfium-81f9eeef041f2974274751d7508598049ae32db2.tar.xz
Convert FX_STRSIZE int->size_t
Change the underlying type for FX_STRSIZE to size_t from int. This will make the value unsigned and thus all values in the range of the type will be valid. This allows for the final remove of negative length strings, but also introduces a some casting and functional errors, since many parts of the code base assume that FX_STRSIZE is int or another signed type. This also CL fixes these errors. BUG=pdfium:828 Change-Id: I231dca59e96fc9330cbb099eecbdfc41fcf86f5b Reviewed-on: https://pdfium-review.googlesource.com/11830 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fgas')
-rw-r--r--xfa/fgas/crt/cfgas_formatstring.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/xfa/fgas/crt/cfgas_formatstring.cpp b/xfa/fgas/crt/cfgas_formatstring.cpp
index 9da8bb9583..df95a3588a 100644
--- a/xfa/fgas/crt/cfgas_formatstring.cpp
+++ b/xfa/fgas/crt/cfgas_formatstring.cpp
@@ -293,7 +293,7 @@ bool ParseLocaleDate(const CFX_WideString& wsDate,
}
}
} else if (symbol == L"YY" || symbol == L"YYYY") {
- if (*cc + symbol.GetLength() > len)
+ if (*cc + pdfium::base::checked_cast<int32_t>(symbol.GetLength()) > len)
return false;
year = 0;
@@ -417,11 +417,13 @@ bool ParseLocaleTime(const CFX_WideString& wsTime,
} else if (symbol == L"A") {
CFX_WideString wsAM = pLocale->GetMeridiemName(true);
CFX_WideString wsPM = pLocale->GetMeridiemName(false);
- if ((*cc + wsAM.GetLength() <= len) &&
+ if ((*cc + pdfium::base::checked_cast<int32_t>(wsAM.GetLength()) <=
+ len) &&
(CFX_WideStringC(str + *cc, wsAM.GetLength()) == wsAM)) {
*cc += wsAM.GetLength();
bHasA = true;
- } else if ((*cc + wsPM.GetLength() <= len) &&
+ } else if ((*cc + pdfium::base::checked_cast<int32_t>(wsPM.GetLength()) <=
+ len) &&
(CFX_WideStringC(str + *cc, wsPM.GetLength()) == wsPM)) {
*cc += wsPM.GetLength();
bHasA = true;
@@ -2087,12 +2089,13 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
if (cc >= 0) {
int nPos = dot_index.value() % 3;
wsOutput->clear();
- for (int32_t i = 0; i < dot_index; i++) {
+ for (int32_t i = 0;
+ i < pdfium::base::checked_cast<int32_t>(dot_index.value()); i++) {
if (i % 3 == nPos && i != 0)
*wsOutput += wsGroupSymbol;
*wsOutput += wsSrcNum[i];
}
- if (dot_index < len) {
+ if (pdfium::base::checked_cast<int32_t>(dot_index.value()) < len) {
*wsOutput += pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Decimal);
*wsOutput += wsSrcNum.Right(len - dot_index.value() - 1);
}
@@ -2102,7 +2105,8 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
}
return false;
}
- if (dot_index_f == wsNumFormat.GetLength()) {
+ if (dot_index_f ==
+ pdfium::base::checked_cast<int32_t>(wsNumFormat.GetLength())) {
if (!bAddNeg && bNeg) {
*wsOutput =
pLocale->GetNumbericSymbol(FX_LOCALENUMSYMBOL_Minus) + *wsOutput;
@@ -2115,7 +2119,7 @@ bool CFGAS_FormatString::FormatStrNum(const CFX_WideStringC& wsInputNum,
if (strf[dot_index_f] == 'V') {
*wsOutput += wsDotSymbol;
} else if (strf[dot_index_f] == '.') {
- if (dot_index < len)
+ if (pdfium::base::checked_cast<int32_t>(dot_index.value()) < len)
*wsOutput += wsDotSymbol;
else if (strf[dot_index_f + 1] == '9' || strf[dot_index_f + 1] == 'Z')
*wsOutput += wsDotSymbol;