diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-30 19:47:59 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-30 19:47:59 +0000 |
commit | 921d24416f310b6a899f09daa4a2628be5be16f3 (patch) | |
tree | 283327a8a7f5fd87eb3e95a0d318e65394395e66 /xfa/fxfa | |
parent | d718d634b7aa3311a5b6298574d06f091365259f (diff) | |
download | pdfium-921d24416f310b6a899f09daa4a2628be5be16f3.tar.xz |
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 <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/cxfa_ffnotify.cpp | 29 |
1 files 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<CXFA_Barcode*>(child)); + if (child->GetElementType() == XFA_Element::Barcode) + pWidget = new CXFA_FFBarcode(pNode, static_cast<CXFA_Barcode*>(child)); break; } case XFA_FFWidgetType::kButton: { CXFA_Node* child = pNode->GetUIChildNode(); - ASSERT(child->GetElementType() == XFA_Element::Button); - pWidget = new CXFA_FFPushButton(pNode, static_cast<CXFA_Button*>(child)); + if (child->GetElementType() == XFA_Element::Button) { + pWidget = + new CXFA_FFPushButton(pNode, static_cast<CXFA_Button*>(child)); + } break; } case XFA_FFWidgetType::kCheckButton: { CXFA_Node* child = pNode->GetUIChildNode(); - ASSERT(child->GetElementType() == XFA_Element::CheckButton); - pWidget = - new CXFA_FFCheckButton(pNode, static_cast<CXFA_CheckButton*>(child)); + if (child->GetElementType() == XFA_Element::CheckButton) { + pWidget = new CXFA_FFCheckButton(pNode, + static_cast<CXFA_CheckButton*>(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<CXFA_PasswordEdit*>(child)); + if (child->GetElementType() == XFA_Element::PasswordEdit) { + pWidget = new CXFA_FFPasswordEdit( + pNode, static_cast<CXFA_PasswordEdit*>(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; } |