From 96b0d1332430e34219334373aeb0f6a85eb8ad68 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 25 Jul 2018 17:04:49 +0000 Subject: Introduce ToXMLElement() checked downcast helper function And use it in place of ASSERT() that the type was correct. Since we can check it, doing so at runtime may help avoid type confusion, and we'll get a nice safe SEGV if the asserted condition ever fails. Change-Id: I46b65a4b70e819a670d7cad7966e0d100f0d9a63 Reviewed-on: https://pdfium-review.googlesource.com/38810 Commit-Queue: Tom Sepez Reviewed-by: Lei Zhang --- xfa/fxfa/parser/cxfa_document.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'xfa/fxfa/parser/cxfa_document.cpp') diff --git a/xfa/fxfa/parser/cxfa_document.cpp b/xfa/fxfa/parser/cxfa_document.cpp index 5a85482b17..3e8046677a 100644 --- a/xfa/fxfa/parser/cxfa_document.cpp +++ b/xfa/fxfa/parser/cxfa_document.cpp @@ -539,10 +539,9 @@ void CreateDataBinding(CXFA_Node* pFormNode, false); } } else { - CFX_XMLNode* pXMLNode = pDataNode->GetXMLMappingNode(); - ASSERT(pXMLNode->GetType() == FX_XMLNODE_Element); - static_cast(pXMLNode)->SetAttribute( - L"xfa:dataNode", L"dataGroup"); + CFX_XMLElement* pElement = + ToXMLElement(pDataNode->GetXMLMappingNode()); + pElement->SetAttribute(L"xfa:dataNode", L"dataGroup"); } } else if (!wsValue.IsEmpty()) { pDataNode->JSObject()->SetAttributeValue( -- cgit v1.2.3