Avoid some crashes in CXFA_ViewLayoutProcessor.
Also remove an assertion that can fail.
Bug: chromium:925791
Change-Id: Ib7bf24ba0e8290ac9abaa3e56a875a2f87834a9b
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59571
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
index 0556cd1..97a89e0 100644
--- a/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
+++ b/xfa/fxfa/layout/cxfa_viewlayoutprocessor.cpp
@@ -532,6 +532,9 @@
const RetainPtr<CXFA_ContentLayoutItem>& pContentLayoutItem,
CXFA_ContentLayoutProcessor::Result eStatus) {
if (pContentLayoutItem) {
+ if (!HasCurrentViewRecord())
+ return;
+
GetCurrentViewRecord()->pCurContentArea->AppendLastChild(
pContentLayoutItem);
m_bCreateOverFlowPage = false;
@@ -548,6 +551,9 @@
}
float CXFA_ViewLayoutProcessor::GetAvailHeight() {
+ if (!HasCurrentViewRecord())
+ return 0.0f;
+
RetainPtr<CXFA_ViewLayoutItem> pLayoutItem =
GetCurrentViewRecord()->pCurContentArea;
if (!pLayoutItem || !pLayoutItem->GetFormNode())
@@ -1305,7 +1311,6 @@
if (!m_pCurPageArea) {
FindPageAreaFromPageSet(m_pTemplatePageSetRoot, nullptr, pTargetPageArea,
pTargetContentArea, bNewPage, bQuery);
- ASSERT(m_pCurPageArea);
return m_pCurPageArea;
}
@@ -1500,6 +1505,9 @@
}
void CXFA_ViewLayoutProcessor::ProcessLastPageSet() {
+ if (!m_pCurPageArea)
+ return;
+
CreateMinPageRecord(m_pCurPageArea, false, true);
CreateNextMinRecord(m_pCurPageArea);
CXFA_Node* pPageSet = m_pCurPageArea->GetParent();