From 6add19c6e183363f543585ce316b54ee9f50592a Mon Sep 17 00:00:00 2001 From: Jun Fang Date: Tue, 23 Feb 2016 09:17:30 +0800 Subject: Fix a crasher in CXFA_LayoutPageMgr::GetAvailHeight() BUG=pdfium:407 R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1717243002 . --- xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp b/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp index 832e1ba5d1..4030326964 100644 --- a/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp +++ b/xfa/src/fxfa/src/parser/xfa_layout_pagemgr_new.cpp @@ -251,19 +251,19 @@ void CXFA_LayoutPageMgr::SubmitContentItem( } } FX_FLOAT CXFA_LayoutPageMgr::GetAvailHeight() { + CXFA_ContainerLayoutItem* pLayoutItem = + GetCurrentContainerRecord()->pCurContentArea; + if (!pLayoutItem || !pLayoutItem->m_pFormNode) + return 0.0f; FX_FLOAT fAvailHeight = - GetCurrentContainerRecord() - ->pCurContentArea->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H) - .ToUnit(XFA_UNIT_Pt); - if (fAvailHeight < XFA_LAYOUT_FLOAT_PERCISION) { - if (m_pCurrentContainerRecord == - m_rgProposedContainerRecord.GetHeadPosition()) { - fAvailHeight = 0; - } else { - fAvailHeight = XFA_LAYOUT_FLOAT_MAX; - } - } - return fAvailHeight; + pLayoutItem->m_pFormNode->GetMeasure(XFA_ATTRIBUTE_H).ToUnit(XFA_UNIT_Pt); + if (fAvailHeight >= XFA_LAYOUT_FLOAT_PERCISION) + return fAvailHeight; + if (m_pCurrentContainerRecord == + m_rgProposedContainerRecord.GetHeadPosition()) { + return 0.0f; + } + return XFA_LAYOUT_FLOAT_MAX; } static CXFA_Node* XFA_ResolveBreakTarget(CXFA_Node* pPageSetRoot, FX_BOOL bNewExprStyle, -- cgit v1.2.3