From 0ac36018b464f74419b8b8e77d9452b41440187a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 1 Aug 2018 08:13:55 +0000 Subject: 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 Commit-Queue: Lei Zhang --- xfa/fxfa/parser/cxfa_localevalue.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp index 15082ae5e3..c201f88ef2 100644 --- a/xfa/fxfa/parser/cxfa_localevalue.cpp +++ b/xfa/fxfa/parser/cxfa_localevalue.cpp @@ -99,6 +99,9 @@ bool CXFA_LocaleValue::ValidateValue(const WideString& wsValue, 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 @@ bool CXFA_LocaleValue::ValidateValue(const WideString& wsValue, pFormat->SplitFormatString(wsPattern, &wsPatterns); bool bRet = false; - int32_t iCount = pdfium::CollectionSize(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); -- cgit v1.2.3