Fix a nullptr crash in CXFA_LocaleValue::ValidateValue().
Fix some nits as well.
BUG=chromium:868271
Change-Id: Ia3231fde98c3e16e41b092a9833402cedc8e828d
Reviewed-on: https://pdfium-review.googlesource.com/39112
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 15082ae..c201f88 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -99,6 +99,9 @@
const WideString& wsPattern,
LocaleIface* pLocale,
WideString* pMatchFormat) {
+ if (!m_pLocaleMgr)
+ return false;
+
WideString wsOutput;
LocaleIface* locale = m_pLocaleMgr->GetDefLocale();
if (pLocale)
@@ -109,10 +112,9 @@
pFormat->SplitFormatString(wsPattern, &wsPatterns);
bool bRet = false;
- int32_t iCount = pdfium::CollectionSize<int32_t>(wsPatterns);
- int32_t i = 0;
- for (; i < iCount && !bRet; i++) {
- WideString wsFormat = wsPatterns[i];
+ size_t i = 0;
+ for (; !bRet && i < wsPatterns.size(); i++) {
+ const WideString& wsFormat = wsPatterns[i];
switch (ValueCategory(pFormat->GetCategory(wsFormat), m_dwType)) {
case FX_LOCALECATEGORY_Null:
bRet = pFormat->ParseNull(wsValue, wsFormat);