summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdf_formfill.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-05-01 17:46:34 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-01 17:46:34 +0000
commit3f3c39d04fd68d8ce11f52baa3acae8e0522a2c4 (patch)
tree6126bc07b3e212f758dfa4e13462fb7bfaa6d97f /fpdfsdk/fpdf_formfill.cpp
parentfe06d5109cd575c1e53b9b1cc3cc4ec3c5d7364f (diff)
downloadpdfium-3f3c39d04fd68d8ce11f52baa3acae8e0522a2c4.tar.xz
Check for NULL XFA context even when XFA
Use strict typing for FPDF_Page to ensure we don't fall into code that expects the other page type when continuing from null context case. Change-Id: I7f028ef3e3d733f5557620030a87e22997da00d5 Reviewed-on: https://pdfium-review.googlesource.com/31770 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'fpdfsdk/fpdf_formfill.cpp')
-rw-r--r--fpdfsdk/fpdf_formfill.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/fpdfsdk/fpdf_formfill.cpp b/fpdfsdk/fpdf_formfill.cpp
index 3170627cd5..202835cb57 100644
--- a/fpdfsdk/fpdf_formfill.cpp
+++ b/fpdfsdk/fpdf_formfill.cpp
@@ -185,7 +185,8 @@ void FFLCommon(FPDF_FORMHANDLE hHandle,
#else // PDF_ENABLE_XFA
options.SetOCContext(pdfium::MakeRetain<CPDF_OCContext>(
pPage->m_pDocument.Get(), CPDF_OCContext::View));
- if (CPDFSDK_PageView* pPageView = FormHandleToPageView(hHandle, pPage))
+ if (CPDFSDK_PageView* pPageView =
+ FormHandleToPageView(hHandle, FPDFPageFromUnderlying(pPage)))
pPageView->PageView_OnDraw(pDevice.get(), &matrix, &options);
#endif // PDF_ENABLE_XFA
}
@@ -296,7 +297,7 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
// this and can just return the old Env. Otherwise, we'll end up setting a new
// environment into the XFADocument and, that could get weird.
auto* pContext = static_cast<CPDFXFA_Context*>(pDocument->GetExtension());
- if (pContext->GetFormFillEnv())
+ if (pContext && pContext->GetFormFillEnv())
return pContext->GetFormFillEnv();
#endif
@@ -304,7 +305,8 @@ FPDFDOC_InitFormFillEnvironment(FPDF_DOCUMENT document,
CPDFDocumentFromFPDFDocument(document), formInfo);
#ifdef PDF_ENABLE_XFA
- pContext->SetFormFillEnv(pFormFillEnv.get());
+ if (pContext)
+ pContext->SetFormFillEnv(pFormFillEnv.get());
#endif // PDF_ENABLE_XFA
return pFormFillEnv.release(); // Caller takes ownership.