diff options
author | Tom Sepez <tsepez@chromium.org> | 2016-05-16 15:56:53 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2016-05-16 15:56:53 -0700 |
commit | d3743ea4e62e870724be26d423c90204c8639463 (patch) | |
tree | f54ee0cd640a9480341844dac86a4178892c94e5 /xfa | |
parent | fa34e805fd03ba81bcfe1148cf96b24fe63b39a0 (diff) | |
download | pdfium-d3743ea4e62e870724be26d423c90204c8639463.tar.xz |
Revert "Replace Release() { delete this; } in fde_xml_imp.h"
This reverts commit fa34e805fd03ba81bcfe1148cf96b24fe63b39a0.
Reason for revert: broke asan tests.
TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1982843002 .
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 56 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.h | 89 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffdoc.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_imp.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_serialize.cpp | 27 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_object_imp.cpp | 26 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_parser.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_parser_imp.cpp | 22 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_parser_imp.h | 18 |
10 files changed, 129 insertions, 130 deletions
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index f630a8995e..446db86950 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -77,17 +77,15 @@ CFDE_XMLNode::CFDE_XMLNode() CFDE_XMLNode::~CFDE_XMLNode() { DeleteChildren(); } - void CFDE_XMLNode::DeleteChildren() { - CFDE_XMLNode* pChild = m_pChild; - while (pChild) { - CFDE_XMLNode* pNext = pChild->m_pNext; - delete pChild; - pChild = pNext; + CFDE_XMLNode *pChild = m_pChild, *pTemp; + while (pChild != NULL) { + pTemp = pChild->m_pNext; + pChild->Release(); + pChild = pTemp; } - m_pChild = nullptr; + m_pChild = NULL; } - int32_t CFDE_XMLNode::CountChildNodes() const { int32_t iCount = 0; CFDE_XMLNode* pChild = m_pChild; @@ -512,9 +510,6 @@ CFDE_XMLInstruction::CFDE_XMLInstruction(const CFX_WideString& wsTarget) : m_wsTarget(wsTarget) { ASSERT(m_wsTarget.GetLength() > 0); } - -CFDE_XMLInstruction::~CFDE_XMLInstruction() {} - CFDE_XMLNode* CFDE_XMLInstruction::Clone(FX_BOOL bRecursive) { CFDE_XMLInstruction* pClone = new CFDE_XMLInstruction(m_wsTarget); if (!pClone) { @@ -832,12 +827,8 @@ void CFDE_XMLElement::SetTextData(const CFX_WideString& wsText) { } InsertChildNode(new CFDE_XMLText(wsText)); } - CFDE_XMLText::CFDE_XMLText(const CFX_WideString& wsText) : CFDE_XMLNode(), m_wsText(wsText) {} - -CFDE_XMLText::~CFDE_XMLText() {} - CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { CFDE_XMLText* pClone = new CFDE_XMLText(m_wsText); return pClone; @@ -845,9 +836,6 @@ CFDE_XMLNode* CFDE_XMLText::Clone(FX_BOOL bRecursive) { CFDE_XMLCharData::CFDE_XMLCharData(const CFX_WideString& wsCData) : CFDE_XMLDeclaration(), m_wsCharData(wsCData) {} - -CFDE_XMLCharData::~CFDE_XMLCharData() {} - CFDE_XMLNode* CFDE_XMLCharData::Clone(FX_BOOL bRecursive) { CFDE_XMLCharData* pClone = new CFDE_XMLCharData(m_wsCharData); return pClone; @@ -872,19 +860,23 @@ void CFDE_XMLDoc::Reset(FX_BOOL bInitRoot) { m_pRoot->DeleteChildren(); } } else { - delete m_pRoot; - m_pRoot = nullptr; + if (m_pRoot != NULL) { + m_pRoot->Release(); + m_pRoot = NULL; + } } ReleaseParser(); } - void CFDE_XMLDoc::ReleaseParser() { - delete m_pXMLParser; - m_pXMLParser = nullptr; - delete m_pSyntaxParser; - m_pSyntaxParser = nullptr; + if (m_pXMLParser != NULL) { + m_pXMLParser->Release(); + m_pXMLParser = NULL; + } + if (m_pSyntaxParser != NULL) { + m_pSyntaxParser->Release(); + m_pSyntaxParser = NULL; + } } - FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, int32_t iXMLPlaneSize, int32_t iTextDataSize, @@ -927,23 +919,21 @@ FX_BOOL CFDE_XMLDoc::LoadXML(IFX_Stream* pXMLStream, } return TRUE; } - -FX_BOOL CFDE_XMLDoc::LoadXML(IFDE_XMLParser* pXMLParser) { - if (!pXMLParser) +FX_BOOL CFDE_XMLDoc::LoadXML(CFDE_XMLParser* pXMLParser) { + if (pXMLParser == NULL) { return FALSE; - + } Reset(TRUE); m_pXMLParser = pXMLParser; - return TRUE; + return m_pXMLParser != NULL; } - int32_t CFDE_XMLDoc::DoLoad(IFX_Pause* pPause) { if (m_iStatus >= 100) { return m_iStatus; } + ASSERT(m_pXMLParser != NULL); return m_iStatus = m_pXMLParser->DoParser(pPause); } - void CFDE_XMLDoc::CloseXML() { ReleaseParser(); } diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h index 78e39b6f22..bad970e5be 100644 --- a/xfa/fde/xml/fde_xml_imp.h +++ b/xfa/fde/xml/fde_xml_imp.h @@ -18,9 +18,9 @@ class CFDE_XMLElement; class CFDE_XMLText; class CFDE_XMLDoc; class CFDE_XMLDOMParser; +class CFDE_XMLParser; class CFDE_XMLSAXParser; class CFDE_XMLSyntaxParser; -class IFDE_XMLParser; class CFDE_XMLNode : public CFX_Target { public: @@ -40,8 +40,8 @@ class CFDE_XMLNode : public CFX_Target { }; CFDE_XMLNode(); - ~CFDE_XMLNode() override; + virtual void Release() { delete this; } virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Unknown; } virtual int32_t CountChildNodes() const; virtual CFDE_XMLNode* GetChildNode(int32_t index) const; @@ -60,22 +60,20 @@ class CFDE_XMLNode : public CFX_Target { virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); virtual void SaveXMLNode(IFX_Stream* pXMLStream); + public: + ~CFDE_XMLNode(); void CloneChildren(CFDE_XMLNode* pClone); - CFDE_XMLNode* m_pParent; CFDE_XMLNode* m_pChild; CFDE_XMLNode* m_pPrior; CFDE_XMLNode* m_pNext; }; - class CFDE_XMLInstruction : public CFDE_XMLNode { public: CFDE_XMLInstruction(const CFX_WideString& wsTarget); - ~CFDE_XMLInstruction() override; - - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Instruction; } - CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; - + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Instruction; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); virtual void GetTargetName(CFX_WideString& wsTarget) const { wsTarget = m_wsTarget; } @@ -101,19 +99,18 @@ class CFDE_XMLInstruction : public CFDE_XMLNode { virtual void AppendData(const CFX_WideString& wsData); virtual void RemoveData(int32_t index); + public: + ~CFDE_XMLInstruction() {} CFX_WideString m_wsTarget; CFX_WideStringArray m_Attributes; CFX_WideStringArray m_TargetData; }; - class CFDE_XMLElement : public CFDE_XMLNode { public: CFDE_XMLElement(const CFX_WideString& wsTag); - ~CFDE_XMLElement() override; - - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Element; } - CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; - + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Element; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); virtual void GetTagName(CFX_WideString& wsTag) const; virtual void GetLocalTagName(CFX_WideString& wsTag) const; virtual void GetNamespacePrefix(CFX_WideString& wsPrefix) const; @@ -138,37 +135,35 @@ class CFDE_XMLElement : public CFDE_XMLNode { virtual void GetTextData(CFX_WideString& wsText) const; virtual void SetTextData(const CFX_WideString& wsText); + public: + ~CFDE_XMLElement(); CFX_WideString m_wsTag; CFX_WideStringArray m_Attributes; }; - class CFDE_XMLText : public CFDE_XMLNode { public: CFDE_XMLText(const CFX_WideString& wsText); - ~CFDE_XMLText() override; - - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_Text; } - CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; - + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_Text; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); virtual void GetText(CFX_WideString& wsText) const { wsText = m_wsText; } virtual void SetText(const CFX_WideString& wsText) { m_wsText = wsText; } + public: + ~CFDE_XMLText() {} CFX_WideString m_wsText; }; - class CFDE_XMLDeclaration : public CFDE_XMLNode { public: CFDE_XMLDeclaration() : CFDE_XMLNode() {} }; - class CFDE_XMLCharData : public CFDE_XMLDeclaration { public: CFDE_XMLCharData(const CFX_WideString& wsCData); - ~CFDE_XMLCharData() override; - - FDE_XMLNODETYPE GetType() const override { return FDE_XMLNODE_CharData; } - CFDE_XMLNode* Clone(FX_BOOL bRecursive) override; + virtual void Release() { delete this; } + virtual FDE_XMLNODETYPE GetType() const { return FDE_XMLNODE_CharData; } + virtual CFDE_XMLNode* Clone(FX_BOOL bRecursive); virtual void GetCharData(CFX_WideString& wsCharData) const { wsCharData = m_wsCharData; } @@ -176,19 +171,21 @@ class CFDE_XMLCharData : public CFDE_XMLDeclaration { m_wsCharData = wsCData; } + public: + ~CFDE_XMLCharData() {} + CFX_WideString m_wsCharData; }; - class CFDE_XMLDoc : public CFX_Target { public: CFDE_XMLDoc(); - ~CFDE_XMLDoc() override; - + ~CFDE_XMLDoc(); + virtual void Release() { delete this; } virtual FX_BOOL LoadXML(IFX_Stream* pXMLStream, int32_t iXMLPlaneSize = 8192, int32_t iTextDataSize = 256, FDE_XMLREADERHANDLER* pHandler = NULL); - virtual FX_BOOL LoadXML(IFDE_XMLParser* pXMLParser); + virtual FX_BOOL LoadXML(CFDE_XMLParser* pXMLParser); virtual int32_t DoLoad(IFX_Pause* pPause = NULL); virtual void CloseXML(); virtual CFDE_XMLNode* GetRoot() const { return m_pRoot; } @@ -200,25 +197,27 @@ class CFDE_XMLDoc : public CFX_Target { int32_t m_iStatus; CFDE_XMLNode* m_pRoot; CFDE_XMLSyntaxParser* m_pSyntaxParser; - IFDE_XMLParser* m_pXMLParser; + CFDE_XMLParser* m_pXMLParser; void Reset(FX_BOOL bInitRoot); void ReleaseParser(); }; typedef CFX_StackTemplate<CFDE_XMLNode*> CFDE_XMLDOMNodeStack; -class IFDE_XMLParser { +class CFDE_XMLParser { public: - virtual ~IFDE_XMLParser() {} + virtual ~CFDE_XMLParser() {} + virtual void Release() = 0; virtual int32_t DoParser(IFX_Pause* pPause) = 0; }; -class CFDE_XMLDOMParser : public IFDE_XMLParser, public CFX_Target { +class CFDE_XMLDOMParser : public CFDE_XMLParser, public CFX_Target { public: CFDE_XMLDOMParser(CFDE_XMLNode* pRoot, CFDE_XMLSyntaxParser* pParser); - ~CFDE_XMLDOMParser() override; + ~CFDE_XMLDOMParser(); - int32_t DoParser(IFX_Pause* pPause) override; + virtual void Release() { delete this; } + virtual int32_t DoParser(IFX_Pause* pPause); private: CFDE_XMLSyntaxParser* m_pParser; @@ -237,14 +236,14 @@ class CFDE_XMLTAG : public CFX_Target { FDE_XMLNODETYPE eType; }; typedef CFX_ObjectStackTemplate<CFDE_XMLTAG> CFDE_XMLTagStack; - -class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target { +class CFDE_XMLSAXParser : public CFDE_XMLParser, public CFX_Target { public: CFDE_XMLSAXParser(FDE_XMLREADERHANDLER* pHandler, CFDE_XMLSyntaxParser* pParser); - ~CFDE_XMLSAXParser() override; + ~CFDE_XMLSAXParser(); - int32_t DoParser(IFX_Pause* pPause) override; + virtual void Release() { delete this; } + virtual int32_t DoParser(IFX_Pause* pPause); private: void Push(const CFDE_XMLTAG& xmlTag); @@ -260,11 +259,11 @@ class CFDE_XMLSAXParser : public IFDE_XMLParser, public CFX_Target { class CFDE_BlockBuffer : public CFX_Target { public: CFDE_BlockBuffer(int32_t iAllocStep = 1024 * 1024); - ~CFDE_BlockBuffer() override; + ~CFDE_BlockBuffer(); FX_BOOL InitBuffer(int32_t iBufferSize = 1024 * 1024); FX_BOOL IsInitialized() { return m_iBufferSize / m_iAllocStep >= 1; } - + void ReleaseBuffer() { delete this; } FX_WCHAR* GetAvailableBlock(int32_t& iIndexInBlock); inline int32_t GetAllocStep() const { return m_iAllocStep; } inline int32_t& GetDataLengthRef() { return m_iDataLength; } @@ -295,8 +294,8 @@ class CFDE_BlockBuffer : public CFX_Target { class CFDE_XMLSyntaxParser : public CFX_Target { public: CFDE_XMLSyntaxParser(); - ~CFDE_XMLSyntaxParser() override; - + ~CFDE_XMLSyntaxParser(); + void Release() { delete this; } void Init(IFX_Stream* pStream, int32_t iXMLPlaneSize, int32_t iTextDataSize = 256); diff --git a/xfa/fxfa/app/xfa_ffdoc.cpp b/xfa/fxfa/app/xfa_ffdoc.cpp index 77c3b251a2..f33e4e0585 100644 --- a/xfa/fxfa/app/xfa_ffdoc.cpp +++ b/xfa/fxfa/app/xfa_ffdoc.cpp @@ -7,7 +7,6 @@ #include "xfa/fxfa/include/xfa_ffdoc.h" #include <algorithm> -#include <memory> #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" @@ -146,11 +145,10 @@ int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { if (!OpenDoc(pPDFDocument)) { return XFA_PARSESTATUS_SyntaxErr; } - std::unique_ptr<IXFA_Parser> pParser( - IXFA_Parser::Create(m_pDocument, TRUE)); - if (!pParser) + IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument, TRUE); + if (!pParser) { return XFA_PARSESTATUS_SyntaxErr; - + } CXFA_Node* pRootNode = NULL; if (pParser->StartParse(m_pStream) == XFA_PARSESTATUS_Ready && pParser->DoParse(NULL) == XFA_PARSESTATUS_Done) { @@ -162,6 +160,8 @@ int32_t CXFA_FFDoc::DoLoad(IFX_Pause* pPause) { } else { iStatus = XFA_PARSESTATUS_StatusErr; } + pParser->Release(); + pParser = NULL; } return iStatus; } @@ -265,7 +265,7 @@ FX_BOOL CXFA_FFDoc::CloseDoc() { m_TypeToDocViewMap.clear(); if (m_pDocument) { - m_pDocument->DestroyParser(); + m_pDocument->GetParser()->Release(); m_pDocument = nullptr; } diff --git a/xfa/fxfa/parser/xfa_document.h b/xfa/fxfa/parser/xfa_document.h index 8501e5fc60..16428ea781 100644 --- a/xfa/fxfa/parser/xfa_document.h +++ b/xfa/fxfa/parser/xfa_document.h @@ -67,7 +67,6 @@ class CXFA_Document { ~CXFA_Document(); CXFA_Node* GetRoot() const { return m_pRootNode; } CXFA_DocumentParser* GetParser() const { return m_pParser; } - void DestroyParser(); CXFA_FFNotify* GetNotify() const; void SetRoot(CXFA_Node* pNewRoot); CXFA_Object* GetXFAObject(const CFX_WideStringC& wsNodeName); diff --git a/xfa/fxfa/parser/xfa_document_imp.cpp b/xfa/fxfa/parser/xfa_document_imp.cpp index 3f1737a7f8..0421683e07 100644 --- a/xfa/fxfa/parser/xfa_document_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_imp.cpp @@ -77,12 +77,6 @@ void CXFA_Document::SetRoot(CXFA_Node* pNewRoot) { m_pRootNode = pNewRoot; RemovePurgeNode(pNewRoot); } - -void CXFA_Document::DestroyParser() { - delete m_pParser; - m_pParser = nullptr; -} - CXFA_FFNotify* CXFA_Document::GetNotify() const { return m_pParser->GetNotify(); } diff --git a/xfa/fxfa/parser/xfa_document_serialize.cpp b/xfa/fxfa/parser/xfa_document_serialize.cpp index 2e300505b3..ef85d0e266 100644 --- a/xfa/fxfa/parser/xfa_document_serialize.cpp +++ b/xfa/fxfa/parser/xfa_document_serialize.cpp @@ -6,8 +6,6 @@ #include "xfa/fxfa/parser/xfa_document_serialize.h" -#include <memory> - #include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fgas/crt/fgas_codepage.h" #include "xfa/fxfa/fm2js/xfa_fm2jsapi.h" @@ -24,26 +22,31 @@ CXFA_DataImporter::CXFA_DataImporter(CXFA_Document* pDocument) : m_pDocument(pDocument) { ASSERT(m_pDocument); } - FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) { - std::unique_ptr<IXFA_Parser> pDataDocumentParser( - IXFA_Parser::Create(m_pDocument)); + IXFA_Parser* pDataDocumentParser = IXFA_Parser::Create(m_pDocument); + if (!pDataDocumentParser) { + return FALSE; + } if (pDataDocumentParser->StartParse(pDataDocument, XFA_XDPPACKET_Datasets) != XFA_PARSESTATUS_Ready) { + pDataDocumentParser->Release(); return FALSE; } - if (pDataDocumentParser->DoParse(nullptr) < XFA_PARSESTATUS_Done) + if (pDataDocumentParser->DoParse(NULL) < XFA_PARSESTATUS_Done) { + pDataDocumentParser->Release(); return FALSE; - + } CXFA_Node* pImportDataRoot = pDataDocumentParser->GetRootNode(); - if (!pImportDataRoot) + if (!pImportDataRoot) { + pDataDocumentParser->Release(); return FALSE; - + } CXFA_Node* pDataModel = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Datasets)); - if (!pDataModel) + if (!pDataModel) { + pDataDocumentParser->Release(); return FALSE; - + } CXFA_Node* pDataNode = ToNode(m_pDocument->GetXFAObject(XFA_HASHCODE_Data)); if (pDataNode) { pDataModel->RemoveChild(pDataNode); @@ -63,9 +66,9 @@ FX_BOOL CXFA_DataImporter::ImportData(IFX_FileRead* pDataDocument) { pDataModel->InsertChild(pImportDataRoot); } m_pDocument->DoDataRemerge(FALSE); + pDataDocumentParser->Release(); return TRUE; } - CFX_WideString XFA_ExportEncodeAttribute(const CFX_WideString& str) { CFX_WideTextBuf textBuf; int32_t iLen = str.GetLength(); diff --git a/xfa/fxfa/parser/xfa_object_imp.cpp b/xfa/fxfa/parser/xfa_object_imp.cpp index f9887825f5..0fbde1f160 100644 --- a/xfa/fxfa/parser/xfa_object_imp.cpp +++ b/xfa/fxfa/parser/xfa_object_imp.cpp @@ -120,10 +120,10 @@ CXFA_Node::~CXFA_Node() { delete pNode; pNode = pNext; } - if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) - delete m_pXMLNode; + if (m_pXMLNode && HasFlag(XFA_NODEFLAG_OwnXMLNode)) { + m_pXMLNode->Release(); + } } - CXFA_Node* CXFA_Node::Clone(FX_BOOL bRecursive) { CXFA_Document* pFactory = m_pDocument->GetParser()->GetFactory(); CXFA_Node* pClone = pFactory->CreateNode(m_ePacket, m_eNodeClass); @@ -962,12 +962,17 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { if (iLength >= 3) { bOverwrite = pArguments->GetInt32(2) == 0 ? FALSE : TRUE; } - std::unique_ptr<IXFA_Parser> pParser(IXFA_Parser::Create(m_pDocument)); + IXFA_Parser* pParser = IXFA_Parser::Create(m_pDocument); + if (!pParser) { + return; + } CFDE_XMLNode* pXMLNode = NULL; int32_t iParserStatus = pParser->ParseXMLData(wsExpression, pXMLNode, NULL); - if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) + if (iParserStatus != XFA_PARSESTATUS_Done || !pXMLNode) { + pParser->Release(); + pParser = NULL; return; - + } if (bIgnoreRoot && (pXMLNode->GetType() != FDE_XMLNODE_Element || XFA_RecognizeRichText(static_cast<CFDE_XMLElement*>(pXMLNode)))) { @@ -1054,11 +1059,14 @@ void CXFA_Node::Script_NodeClass_LoadXML(CFXJSE_Arguments* pArguments) { } pFakeRoot->SetFlag(XFA_NODEFLAG_HasRemoved, false); } else { - delete pFakeXMLRoot; - pFakeXMLRoot = nullptr; + if (pFakeXMLRoot) { + pFakeXMLRoot->Release(); + pFakeXMLRoot = NULL; + } } + pParser->Release(); + pParser = NULL; } - void CXFA_Node::Script_NodeClass_SaveFilteredXML(CFXJSE_Arguments* pArguments) { } diff --git a/xfa/fxfa/parser/xfa_parser.h b/xfa/fxfa/parser/xfa_parser.h index 656653698e..5ccc1af199 100644 --- a/xfa/fxfa/parser/xfa_parser.h +++ b/xfa/fxfa/parser/xfa_parser.h @@ -16,7 +16,7 @@ class IXFA_Parser { static IXFA_Parser* Create(CXFA_Document* pFactory, FX_BOOL bDocumentParser = FALSE); virtual ~IXFA_Parser() {} - + virtual void Release() = 0; virtual int32_t StartParse(IFX_FileRead* pStream, XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP) = 0; virtual int32_t DoParse(IFX_Pause* pPause = NULL) = 0; diff --git a/xfa/fxfa/parser/xfa_parser_imp.cpp b/xfa/fxfa/parser/xfa_parser_imp.cpp index bb4ba864d5..01ea1d6fae 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.cpp +++ b/xfa/fxfa/parser/xfa_parser_imp.cpp @@ -680,9 +680,10 @@ CXFA_Node* CXFA_SimpleParser::ParseAsXDPPacket_Data( CXFA_Node* pNode = m_pFactory->CreateNode(XFA_XDPPACKET_Datasets, XFA_ELEMENT_DataGroup); if (!pNode) { - if (pDataXMLNode != pXMLDocumentNode) - delete pDataXMLNode; - return nullptr; + if (pDataXMLNode != pXMLDocumentNode) { + pDataXMLNode->Release(); + } + return NULL; } CFX_WideString wsLocalName; static_cast<CFDE_XMLElement*>(pDataXMLNode)->GetLocalTagName(wsLocalName); @@ -1334,11 +1335,13 @@ void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode, } } void CXFA_SimpleParser::CloseParser() { - delete m_pXMLDoc; - m_pXMLDoc = nullptr; + if (m_pXMLDoc) { + m_pXMLDoc->Release(); + m_pXMLDoc = NULL; + } if (m_pStream) { m_pStream->Release(); - m_pStream = nullptr; + m_pStream = NULL; } } @@ -1407,16 +1410,17 @@ CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream) m_syntaxParserResult(FDE_XmlSyntaxResult::None) { ASSERT(m_pParent && m_pStream); m_NodeStack.Push(m_pParent); - m_pParser.reset(new CFDE_XMLSyntaxParser); + m_pParser = new CFDE_XMLSyntaxParser; m_pParser->Init(m_pStream, 32 * 1024, 1024 * 1024); } - CXFA_XMLParser::~CXFA_XMLParser() { + if (m_pParser) { + m_pParser->Release(); + } m_NodeStack.RemoveAll(); m_ws1.clear(); m_ws2.clear(); } - int32_t CXFA_XMLParser::DoParser(IFX_Pause* pPause) { if (m_syntaxParserResult == FDE_XmlSyntaxResult::Error) return -1; diff --git a/xfa/fxfa/parser/xfa_parser_imp.h b/xfa/fxfa/parser/xfa_parser_imp.h index eb98966398..2485ddfcd2 100644 --- a/xfa/fxfa/parser/xfa_parser_imp.h +++ b/xfa/fxfa/parser/xfa_parser_imp.h @@ -7,18 +7,18 @@ #ifndef XFA_FXFA_PARSER_XFA_PARSER_IMP_H_ #define XFA_FXFA_PARSER_XFA_PARSER_IMP_H_ -#include <memory> - #include "xfa/fde/xml/fde_xml_imp.h" #include "xfa/fxfa/parser/xfa_parser.h" class CXFA_XMLParser; -class CXFA_SimpleParser final : public IXFA_Parser { +class CXFA_SimpleParser : public IXFA_Parser { public: CXFA_SimpleParser(CXFA_Document* pFactory, FX_BOOL bDocumentParser = FALSE); ~CXFA_SimpleParser() override; + void Release() override { delete this; } + int32_t StartParse(IFX_FileRead* pStream, XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP) override; int32_t DoParse(IFX_Pause* pPause = NULL) override; @@ -82,11 +82,12 @@ class CXFA_SimpleParser final : public IXFA_Parser { friend class CXFA_DocumentParser; }; -class CXFA_DocumentParser final : public IXFA_Parser { +class CXFA_DocumentParser : public IXFA_Parser { public: CXFA_DocumentParser(CXFA_FFNotify* pNotify); ~CXFA_DocumentParser() override; + void Release() override { delete this; } int32_t StartParse(IFX_FileRead* pStream, XFA_XDPPACKET ePacketID = XFA_XDPPACKET_XDP) override; int32_t DoParse(IFX_Pause* pPause = NULL) override; @@ -110,12 +111,13 @@ class CXFA_DocumentParser final : public IXFA_Parser { }; typedef CFX_StackTemplate<CFDE_XMLNode*> CXFA_XMLNodeStack; -class CXFA_XMLParser : public IFDE_XMLParser { +class CXFA_XMLParser : public CFDE_XMLParser { public: CXFA_XMLParser(CFDE_XMLNode* pRoot, IFX_Stream* pStream); - ~CXFA_XMLParser() override; + ~CXFA_XMLParser(); - int32_t DoParser(IFX_Pause* pPause) override; + virtual void Release() { delete this; } + virtual int32_t DoParser(IFX_Pause* pPause); FX_FILESIZE m_nStart[2]; size_t m_nSize[2]; @@ -126,7 +128,7 @@ class CXFA_XMLParser : public IFDE_XMLParser { protected: CFDE_XMLNode* m_pRoot; IFX_Stream* m_pStream; - std::unique_ptr<CFDE_XMLSyntaxParser> m_pParser; + CFDE_XMLSyntaxParser* m_pParser; CFDE_XMLNode* m_pParent; CFDE_XMLNode* m_pChild; CXFA_XMLNodeStack m_NodeStack; |