From 62bd019a37ae0753e8153aa530eac3b291b008c4 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 5 Apr 2017 10:00:14 -0700 Subject: Check first then cast in XFA_FDEExtension_ResolveNamespaceQualifier Bug: 708383 Change-Id: I6d59fb40bbddd4bdc7224d72bfb789d360f029ca Reviewed-on: https://pdfium-review.googlesource.com/3770 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fxfa/parser/cxfa_simple_parser.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp index b3f1302eae..55a85fd6d9 100644 --- a/xfa/fxfa/parser/cxfa_simple_parser.cpp +++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp @@ -412,13 +412,14 @@ bool XFA_FDEExtension_ResolveNamespaceQualifier( } else { wsNSAttribute = L"xmlns:" + wsQualifier; } - for (; pNode != pFakeRoot; pNode = static_cast( - pNode->GetNodeItem(CFDE_XMLNode::Parent))) { - if (pNode->GetType() != FDE_XMLNODE_Element) + for (CFDE_XMLNode* pParent = pNode; pParent != pFakeRoot; + pParent = pParent->GetNodeItem(CFDE_XMLNode::Parent)) { + if (pParent->GetType() != FDE_XMLNODE_Element) continue; - if (pNode->HasAttribute(wsNSAttribute.c_str())) { - *wsNamespaceURI = pNode->GetString(wsNSAttribute.c_str()); + auto* pElement = static_cast(pParent); + if (pElement->HasAttribute(wsNSAttribute.c_str())) { + *wsNamespaceURI = pElement->GetString(wsNSAttribute.c_str()); return true; } } -- cgit v1.2.3