check NULL of pTemplateRoot in DoDataMerge
authorBo Xu <bo_xu@foxitsoftware.com>
Sat, 6 Dec 2014 01:20:03 +0000 (17:20 -0800)
committerBo Xu <bo_xu@foxitsoftware.com>
Sat, 6 Dec 2014 01:20:03 +0000 (17:20 -0800)
BUG= https://code.google.com/p/pdfium/issues/detail?id=89
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/786523004

xfa/src/fxfa/src/parser/xfa_document_datamerger_imp.cpp

index f747cb5..f496e48 100644 (file)
@@ -1125,7 +1125,6 @@ CXFA_Node *       CXFA_Document::GetNotBindNode(CXFA_ObjArray& arrayNodes)
 }\r
 void CXFA_Document::DoDataMerge()\r
 {\r
-    CXFA_Node* pTemplateRoot = m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template);\r
     CXFA_Node* pDatasetsRoot = (CXFA_Node*)GetXFANode(XFA_HASHCODE_Datasets);\r
     if(!pDatasetsRoot) {\r
         IFDE_XMLElement* pDatasetsXMLNode = IFDE_XMLElement::Create(FX_WSTRC(L"xfa:datasets"));\r
@@ -1174,6 +1173,10 @@ void CXFA_Document::DoDataMerge()
     }\r
     CXFA_Node* pDataTopLevel = pDataRoot->GetFirstChildByClass(XFA_ELEMENT_DataGroup);\r
     FX_DWORD dwNameHash = pDataTopLevel ? pDataTopLevel->GetNameHash() : 0;\r
+    CXFA_Node* pTemplateRoot = m_pRootNode->GetFirstChildByClass(XFA_ELEMENT_Template);\r
+    if (!pTemplateRoot) {\r
+        return;\r
+    }\r
     CXFA_Node* pTemplateChosen = dwNameHash != 0 ? pTemplateRoot->GetFirstChildByName(dwNameHash) : NULL;\r
     if(!pTemplateChosen || pTemplateChosen->GetClassID() != XFA_ELEMENT_Subform) {\r
         pTemplateChosen = pTemplateRoot->GetFirstChildByClass(XFA_ELEMENT_Subform);\r