diff options
author | Tom Sepez <tsepez@chromium.org> | 2018-07-25 17:04:49 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-07-25 17:04:49 +0000 |
commit | 96b0d1332430e34219334373aeb0f6a85eb8ad68 (patch) | |
tree | e50f75e447d6c1dff6e50b4b089af5b1a21b475e /xfa/fxfa/parser/cxfa_document_parser.cpp | |
parent | 1f7db295b1deeecb562d6213b3ea17b9168405eb (diff) | |
download | pdfium-96b0d1332430e34219334373aeb0f6a85eb8ad68.tar.xz |
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 <tsepez@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_document_parser.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_document_parser.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp index 8e5ff9fbde..27d80cde15 100644 --- a/xfa/fxfa/parser/cxfa_document_parser.cpp +++ b/xfa/fxfa/parser/cxfa_document_parser.cpp @@ -669,11 +669,9 @@ CXFA_Node* CXFA_DocumentParser::ParseAsXDPPacket_Data( if (pParentXMLNode) pParentXMLNode->RemoveChildNode(pXMLDocumentNode); - ASSERT(pXMLDocumentNode->GetType() == FX_XMLNODE_Element); - if (pXMLDocumentNode->GetType() == FX_XMLNODE_Element) { - static_cast<CFX_XMLElement*>(pXMLDocumentNode) - ->RemoveAttribute(L"xmlns:xfa"); - } + CFX_XMLElement* pElement = ToXMLElement(pXMLDocumentNode); + pElement->RemoveAttribute(L"xmlns:xfa"); + // The node was either removed from the parent above, or already has no // parent so we can take ownership. pDataElement->AppendChild(pXMLDocumentNode); |