From 921d24416f310b6a899f09daa4a2628be5be16f3 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 30 Jul 2018 19:47:59 +0000 Subject: Convert some asserts to ifs in cxfa_ffnotify.cpp. We'll get a nice safe segv should this somehow happen in the wild instead of a type confusion error. We'll assert later on in the debug builds when the null is seen, as well. Change-Id: Iabd8468adcbacaa0acdc7c68f27cc8f94e0e68cc Reviewed-on: https://pdfium-review.googlesource.com/39151 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- xfa/fxfa/cxfa_ffnotify.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index a3e082681e..586b048b8a 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -116,21 +116,24 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem( switch (pNode->GetFFWidgetType()) { case XFA_FFWidgetType::kBarcode: { CXFA_Node* child = pNode->GetUIChildNode(); - ASSERT(child->GetElementType() == XFA_Element::Barcode); - pWidget = new CXFA_FFBarcode(pNode, static_cast(child)); + if (child->GetElementType() == XFA_Element::Barcode) + pWidget = new CXFA_FFBarcode(pNode, static_cast(child)); break; } case XFA_FFWidgetType::kButton: { CXFA_Node* child = pNode->GetUIChildNode(); - ASSERT(child->GetElementType() == XFA_Element::Button); - pWidget = new CXFA_FFPushButton(pNode, static_cast(child)); + if (child->GetElementType() == XFA_Element::Button) { + pWidget = + new CXFA_FFPushButton(pNode, static_cast(child)); + } break; } case XFA_FFWidgetType::kCheckButton: { CXFA_Node* child = pNode->GetUIChildNode(); - ASSERT(child->GetElementType() == XFA_Element::CheckButton); - pWidget = - new CXFA_FFCheckButton(pNode, static_cast(child)); + if (child->GetElementType() == XFA_Element::CheckButton) { + pWidget = new CXFA_FFCheckButton(pNode, + static_cast(child)); + } break; } case XFA_FFWidgetType::kChoiceList: { @@ -138,7 +141,8 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem( pWidget = new CXFA_FFListBox(pNode); else pWidget = new CXFA_FFComboBox(pNode); - } break; + break; + } case XFA_FFWidgetType::kDateTimeEdit: pWidget = new CXFA_FFDateTimeEdit(pNode); break; @@ -150,9 +154,10 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem( break; case XFA_FFWidgetType::kPasswordEdit: { CXFA_Node* child = pNode->GetUIChildNode(); - ASSERT(child->GetElementType() == XFA_Element::PasswordEdit); - pWidget = new CXFA_FFPasswordEdit(pNode, - static_cast(child)); + if (child->GetElementType() == XFA_Element::PasswordEdit) { + pWidget = new CXFA_FFPasswordEdit( + pNode, static_cast(child)); + } break; } case XFA_FFWidgetType::kSignature: @@ -186,10 +191,8 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem( return nullptr; } ASSERT(pWidget); - CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetLayoutProcessor(); pWidget->SetDocView(m_pDoc->GetDocView(pLayout)); - return pWidget; } -- cgit v1.2.3