From 8878029366d3815489384c5cee344e66b6e9f805 Mon Sep 17 00:00:00 2001 From: Jun Fang Date: Tue, 2 Feb 2016 17:19:57 -0800 Subject: XFA: Fix SEGV in CPDFXFA_Document::SetCurrentPage() BUG=pdfium:377 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1658163002 . --- fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp index d37038d2af..df8b839bb1 100644 --- a/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp +++ b/fpdfsdk/src/fpdfxfa/fpdfxfa_doc.cpp @@ -542,15 +542,13 @@ int32_t CPDFXFA_Document::GetCurrentPage(IXFA_Doc* hDoc) { return pEnv->FFI_GetCurrentPageIndex(this); } void CPDFXFA_Document::SetCurrentPage(IXFA_Doc* hDoc, int32_t iCurPage) { - if (hDoc != m_pXFADoc || !m_pSDKDoc) - return; - if (m_iDocType != DOCTYPE_DYNAMIC_XFA) + if (hDoc != m_pXFADoc || !m_pSDKDoc || m_iDocType != DOCTYPE_DYNAMIC_XFA || + iCurPage < 0 || iCurPage >= m_pSDKDoc->GetPageCount()) { return; - + } CPDFDoc_Environment* pEnv = m_pSDKDoc->GetEnv(); - if (pEnv == NULL) + if (!pEnv) return; - pEnv->FFI_SetCurrentPage(this, iCurPage); } FX_BOOL CPDFXFA_Document::IsCalculationsEnabled(IXFA_Doc* hDoc) { -- cgit v1.2.3