summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc4
-rw-r--r--testing/libfuzzer/pdf_css_fuzzer.cc10
-rw-r--r--testing/libfuzzer/pdf_xml_fuzzer.cc6
-rw-r--r--xfa/fde/cfde_txtedtengine.cpp3
-rw-r--r--xfa/fde/cfde_txtedtengine.h3
-rw-r--r--xfa/fde/css/fde_css.h2
-rw-r--r--xfa/fde/css/fde_cssstylesheet.cpp12
-rw-r--r--xfa/fde/css/fde_cssstylesheet.h2
-rw-r--r--xfa/fde/css/fde_csssyntax.cpp21
-rw-r--r--xfa/fde/css/fde_csssyntax.h7
-rw-r--r--xfa/fde/xml/fde_xml_imp.cpp10
-rw-r--r--xfa/fde/xml/fde_xml_imp.h13
-rw-r--r--xfa/fde/xml/fde_xml_imp_unittest.cpp165
-rw-r--r--xfa/fgas/crt/fgas_stream.cpp151
-rw-r--r--xfa/fgas/crt/fgas_stream.h26
-rw-r--r--xfa/fgas/font/cfgas_gefont.cpp14
-rw-r--r--xfa/fgas/font/cfgas_gefont.h7
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.cpp22
-rw-r--r--xfa/fxfa/parser/cxfa_dataexporter.h2
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.cpp20
-rw-r--r--xfa/fxfa/parser/cxfa_simple_parser.h2
-rw-r--r--xfa/fxfa/parser/cxfa_widetextread.cpp19
-rw-r--r--xfa/fxfa/parser/cxfa_widetextread.h9
-rw-r--r--xfa/fxfa/parser/cxfa_xml_parser.cpp3
-rw-r--r--xfa/fxfa/parser/cxfa_xml_parser.h5
-rw-r--r--xfa/fxfa/parser/xfa_utils.h9
27 files changed, 251 insertions, 308 deletions
diff --git a/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc b/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc
index 94decbfc2c..d99457d360 100644
--- a/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc
+++ b/testing/libfuzzer/pdf_cfx_saxreader_fuzzer.cc
@@ -4,6 +4,7 @@
#include <memory>
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/xml/cfx_saxreader.h"
#include "xfa/fgas/crt/fgas_stream.h"
#include "xfa/fxfa/parser/cxfa_widetextread.h"
@@ -11,8 +12,7 @@
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
CFX_WideString input = CFX_WideString::FromUTF8(
CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> stream(
- new CXFA_WideTextRead(input));
+ auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input);
if (!stream)
return 0;
diff --git a/testing/libfuzzer/pdf_css_fuzzer.cc b/testing/libfuzzer/pdf_css_fuzzer.cc
index 96877f40be..247c9b9245 100644
--- a/testing/libfuzzer/pdf_css_fuzzer.cc
+++ b/testing/libfuzzer/pdf_css_fuzzer.cc
@@ -4,6 +4,7 @@
#include <memory>
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "core/fxcrt/fx_string.h"
#include "xfa/fde/css/fde_css.h"
#include "xfa/fde/css/fde_csssyntax.h"
@@ -11,16 +12,15 @@
#include "xfa/fxfa/parser/cxfa_widetextread.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- CFDE_CSSSyntaxParser parser;
-
CFX_WideString input = CFX_WideString::FromUTF8(
CFX_ByteStringC(data, static_cast<FX_STRSIZE>(size)));
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> stream(
- new CXFA_WideTextRead(input));
+
+ auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input);
if (!stream)
return 0;
- parser.Init(stream.get(), 1024);
+ CFDE_CSSSyntaxParser parser;
+ parser.Init(stream, 1024);
FDE_CSSSYNTAXSTATUS status = parser.DoSyntaxParse();
while (status != FDE_CSSSYNTAXSTATUS_Error &&
diff --git a/testing/libfuzzer/pdf_xml_fuzzer.cc b/testing/libfuzzer/pdf_xml_fuzzer.cc
index d28522c2ea..4f000ab78e 100644
--- a/testing/libfuzzer/pdf_xml_fuzzer.cc
+++ b/testing/libfuzzer/pdf_xml_fuzzer.cc
@@ -52,15 +52,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
CFX_WideString input =
CFX_WideString::FromUTF8(CFX_ByteStringC(data, safe_size.ValueOrDie()));
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> stream(
- new CXFA_WideTextRead(input));
+ auto stream = pdfium::MakeRetain<CXFA_WideTextRead>(input);
if (!stream)
return 0;
std::unique_ptr<CFDE_XMLDoc> doc = pdfium::MakeUnique<CFDE_XMLDoc>();
std::unique_ptr<CFDE_XMLParser, ReleaseDeleter<CFDE_XMLParser>> parser(
- new CXFA_XMLParser(doc->GetRoot(), stream.get()));
-
+ new CXFA_XMLParser(doc->GetRoot(), stream));
if (!doc->LoadXML(parser.release()))
return 0;
diff --git a/xfa/fde/cfde_txtedtengine.cpp b/xfa/fde/cfde_txtedtengine.cpp
index 1250043fc7..d9e321f382 100644
--- a/xfa/fde/cfde_txtedtengine.cpp
+++ b/xfa/fde/cfde_txtedtengine.cpp
@@ -107,7 +107,8 @@ IFDE_TxtEdtPage* CFDE_TxtEdtEngine::GetPage(int32_t nIndex) {
return m_PagePtrArray[nIndex];
}
-void CFDE_TxtEdtEngine::SetTextByStream(IFGAS_Stream* pStream) {
+void CFDE_TxtEdtEngine::SetTextByStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pStream) {
ResetEngine();
int32_t nIndex = 0;
if (pStream && pStream->GetLength()) {
diff --git a/xfa/fde/cfde_txtedtengine.h b/xfa/fde/cfde_txtedtengine.h
index bd02c9b9e7..a01f7565fc 100644
--- a/xfa/fde/cfde_txtedtengine.h
+++ b/xfa/fde/cfde_txtedtengine.h
@@ -9,6 +9,7 @@
#include <memory>
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/ifde_txtedtengine.h"
class CFDE_TxtEdtBuf;
@@ -28,7 +29,7 @@ class CFDE_TxtEdtEngine {
int32_t CountPages() const;
IFDE_TxtEdtPage* GetPage(int32_t nIndex);
- void SetTextByStream(IFGAS_Stream* pStream);
+ void SetTextByStream(const CFX_RetainPtr<IFGAS_Stream>& pStream);
void SetText(const CFX_WideString& wsText);
int32_t GetTextLength() const;
CFX_WideString GetText(int32_t nStart, int32_t nCount = -1) const;
diff --git a/xfa/fde/css/fde_css.h b/xfa/fde/css/fde_css.h
index 3c216290d2..15468c2c4a 100644
--- a/xfa/fde/css/fde_css.h
+++ b/xfa/fde/css/fde_css.h
@@ -751,7 +751,7 @@ class IFDE_CSSStyleSheet : public IFX_Retainable {
static IFDE_CSSStyleSheet* LoadHTMLStandardStyleSheet();
static IFDE_CSSStyleSheet* LoadFromStream(
const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage,
uint32_t dwMediaList = FDE_CSSMEDIATYPE_ALL);
static IFDE_CSSStyleSheet* LoadFromBuffer(
diff --git a/xfa/fde/css/fde_cssstylesheet.cpp b/xfa/fde/css/fde_cssstylesheet.cpp
index 9c91e43cce..fbecf4325b 100644
--- a/xfa/fde/css/fde_cssstylesheet.cpp
+++ b/xfa/fde/css/fde_cssstylesheet.cpp
@@ -8,6 +8,7 @@
#include <memory>
+#include "third_party/base/ptr_util.h"
#include "xfa/fde/css/fde_cssdatatable.h"
#include "xfa/fde/css/fde_csssyntax.h"
#include "xfa/fgas/crt/fgas_codepage.h"
@@ -49,7 +50,7 @@ IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadHTMLStandardStyleSheet() {
IFDE_CSSStyleSheet* IFDE_CSSStyleSheet::LoadFromStream(
const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage,
uint32_t dwMediaList) {
CFDE_CSSStyleSheet* pStyleSheet = new CFDE_CSSStyleSheet(dwMediaList);
@@ -143,10 +144,11 @@ IFDE_CSSRule* CFDE_CSSStyleSheet::GetRule(int32_t index) {
return m_RuleArray.GetAt(index);
}
-bool CFDE_CSSStyleSheet::LoadFromStream(const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
- uint16_t wCodePage) {
- std::unique_ptr<CFDE_CSSSyntaxParser> pSyntax(new CFDE_CSSSyntaxParser);
+bool CFDE_CSSStyleSheet::LoadFromStream(
+ const CFX_WideString& szUrl,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ uint16_t wCodePage) {
+ auto pSyntax = pdfium::MakeUnique<CFDE_CSSSyntaxParser>();
if (pStream->GetCodePage() != wCodePage)
pStream->SetCodePage(wCodePage);
diff --git a/xfa/fde/css/fde_cssstylesheet.h b/xfa/fde/css/fde_cssstylesheet.h
index 2460959a97..ad1f8dfbe3 100644
--- a/xfa/fde/css/fde_cssstylesheet.h
+++ b/xfa/fde/css/fde_cssstylesheet.h
@@ -111,7 +111,7 @@ class CFDE_CSSStyleSheet : public IFDE_CSSStyleSheet, public CFX_Target {
IFDE_CSSRule* GetRule(int32_t index) override;
bool LoadFromStream(const CFX_WideString& szUrl,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
uint16_t wCodePage);
bool LoadFromBuffer(const CFX_WideString& szUrl,
const FX_WCHAR* pBuffer,
diff --git a/xfa/fde/css/fde_csssyntax.cpp b/xfa/fde/css/fde_csssyntax.cpp
index bdad0155d5..50ad190857 100644
--- a/xfa/fde/css/fde_csssyntax.cpp
+++ b/xfa/fde/css/fde_csssyntax.cpp
@@ -35,7 +35,7 @@ CFDE_CSSSyntaxParser::~CFDE_CSSSyntaxParser() {
m_TextPlane.Reset();
}
-bool CFDE_CSSSyntaxParser::Init(IFGAS_Stream* pStream,
+bool CFDE_CSSSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize,
bool bOnlyDeclaration) {
@@ -433,22 +433,25 @@ bool CFDE_CSSTextBuf::EstimateSize(int32_t iAllocSize) {
m_bExtBuf = false;
return ExpandBuf(iAllocSize);
}
-int32_t CFDE_CSSTextBuf::LoadFromStream(IFGAS_Stream* pTxtStream,
- int32_t iStreamOffset,
- int32_t iMaxChars,
- bool& bEOS) {
+
+int32_t CFDE_CSSTextBuf::LoadFromStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
+ int32_t iStreamOffset,
+ int32_t iMaxChars,
+ bool& bEOS) {
ASSERT(iStreamOffset >= 0 && iMaxChars > 0);
Clear();
m_bExtBuf = false;
- if (!ExpandBuf(iMaxChars)) {
+ if (!ExpandBuf(iMaxChars))
return 0;
- }
- if (pTxtStream->GetPosition() != iStreamOffset) {
+
+ if (pTxtStream->GetPosition() != iStreamOffset)
pTxtStream->Seek(FX_STREAMSEEK_Begin, iStreamOffset);
- }
+
m_iDatLen = pTxtStream->ReadString(m_pBuffer, iMaxChars, bEOS);
return m_iDatLen;
}
+
bool CFDE_CSSTextBuf::ExpandBuf(int32_t iDesiredSize) {
if (m_bExtBuf) {
return false;
diff --git a/xfa/fde/css/fde_csssyntax.h b/xfa/fde/css/fde_csssyntax.h
index 03662037d9..6417df07d4 100644
--- a/xfa/fde/css/fde_csssyntax.h
+++ b/xfa/fde/css/fde_csssyntax.h
@@ -7,6 +7,7 @@
#ifndef XFA_FDE_CSS_FDE_CSSSYNTAX_H_
#define XFA_FDE_CSS_FDE_CSSSYNTAX_H_
+#include "core/fxcrt/cfx_retain_ptr.h"
#include "xfa/fde/css/fde_css.h"
#include "xfa/fgas/crt/fgas_memory.h"
#include "xfa/fgas/crt/fgas_stream.h"
@@ -18,7 +19,7 @@ class CFDE_CSSTextBuf : public CFX_Target {
bool AttachBuffer(const FX_WCHAR* pBuffer, int32_t iBufLen);
bool EstimateSize(int32_t iAllocSize);
- int32_t LoadFromStream(IFGAS_Stream* pTxtStream,
+ int32_t LoadFromStream(const CFX_RetainPtr<IFGAS_Stream>& pTxtStream,
int32_t iStreamOffset,
int32_t iMaxChars,
bool& bEOS);
@@ -80,7 +81,7 @@ class CFDE_CSSSyntaxParser : public CFX_Target {
CFDE_CSSSyntaxParser();
~CFDE_CSSSyntaxParser() override;
- bool Init(IFGAS_Stream* pStream,
+ bool Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iCSSPlaneSize,
int32_t iTextDataSize = 32,
bool bOnlyDeclaration = false);
@@ -106,7 +107,7 @@ class CFDE_CSSSyntaxParser : public CFX_Target {
bool IsImportEnabled() const;
void DisableImport() { m_dwCheck = 0; }
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iStreamPos;
int32_t m_iPlaneSize;
CFDE_CSSTextBuf m_TextData;
diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp
index 1fbb1cdda7..f333b4fcda 100644
--- a/xfa/fde/xml/fde_xml_imp.cpp
+++ b/xfa/fde/xml/fde_xml_imp.cpp
@@ -394,7 +394,7 @@ CFDE_XMLNode* CFDE_XMLNode::Clone(bool bRecursive) {
return nullptr;
}
-void CFDE_XMLNode::SaveXMLNode(IFGAS_Stream* pXMLStream) {
+void CFDE_XMLNode::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)this;
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
@@ -986,7 +986,8 @@ void CFDE_XMLDoc::CloseXML() {
ReleaseParser();
}
-void CFDE_XMLDoc::SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pINode) {
+void CFDE_XMLDoc::SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ CFDE_XMLNode* pINode) {
CFDE_XMLNode* pNode = (CFDE_XMLNode*)pINode;
switch (pNode->GetType()) {
case FDE_XMLNODE_Instruction: {
@@ -1096,7 +1097,8 @@ void CFDE_XMLDoc::SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pINode) {
}
}
-void CFDE_XMLDoc::SaveXML(IFGAS_Stream* pXMLStream, bool bSaveBOM) {
+void CFDE_XMLDoc::SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ bool bSaveBOM) {
if (!pXMLStream || pXMLStream == m_pStream) {
m_pStream->Seek(FX_STREAMSEEK_Begin, 0);
pXMLStream = m_pStream;
@@ -1288,7 +1290,7 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
m_CurNode.eNodeType = FDE_XMLNODE_Unknown;
}
-void CFDE_XMLSyntaxParser::Init(IFGAS_Stream* pStream,
+void CFDE_XMLSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize) {
ASSERT(!m_pStream && !m_pBuffer);
diff --git a/xfa/fde/xml/fde_xml_imp.h b/xfa/fde/xml/fde_xml_imp.h
index 924f958b86..283184aadc 100644
--- a/xfa/fde/xml/fde_xml_imp.h
+++ b/xfa/fde/xml/fde_xml_imp.h
@@ -63,7 +63,7 @@ class CFDE_XMLNode : public CFX_Target {
bool InsertNodeItem(CFDE_XMLNode::NodeItem eItem, CFDE_XMLNode* pNode);
CFDE_XMLNode* RemoveNodeItem(CFDE_XMLNode::NodeItem eItem);
- void SaveXMLNode(IFGAS_Stream* pXMLStream);
+ void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream);
CFDE_XMLNode* m_pParent;
CFDE_XMLNode* m_pChild;
@@ -197,14 +197,15 @@ class CFDE_XMLDoc : public CFX_Target {
int32_t DoLoad(IFX_Pause* pPause = nullptr);
void CloseXML();
CFDE_XMLNode* GetRoot() const { return m_pRoot; }
- void SaveXML(IFGAS_Stream* pXMLStream = nullptr, bool bSaveBOM = true);
- void SaveXMLNode(IFGAS_Stream* pXMLStream, CFDE_XMLNode* pNode);
+ void SaveXML(CFX_RetainPtr<IFGAS_Stream>& pXMLStream, bool bSaveBOM = true);
+ void SaveXMLNode(const CFX_RetainPtr<IFGAS_Stream>& pXMLStream,
+ CFDE_XMLNode* pNode);
protected:
void Reset(bool bInitRoot);
void ReleaseParser();
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iStatus;
CFDE_XMLNode* m_pRoot;
CFDE_XMLSyntaxParser* m_pSyntaxParser;
@@ -261,7 +262,7 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
~CFDE_XMLSyntaxParser() override;
void Release() { delete this; }
- void Init(IFGAS_Stream* pStream,
+ void Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
int32_t iXMLPlaneSize,
int32_t iTextDataSize = 256);
@@ -320,7 +321,7 @@ class CFDE_XMLSyntaxParser : public CFX_Target {
void ParseTextChar(FX_WCHAR ch);
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
int32_t m_iXMLPlaneSize;
int32_t m_iCurrentPos;
int32_t m_iCurrentNodeNum;
diff --git a/xfa/fde/xml/fde_xml_imp_unittest.cpp b/xfa/fde/xml/fde_xml_imp_unittest.cpp
index 553afffd86..6db1b1905a 100644
--- a/xfa/fde/xml/fde_xml_imp_unittest.cpp
+++ b/xfa/fde/xml/fde_xml_imp_unittest.cpp
@@ -26,15 +26,14 @@ TEST(CFDE_XMLSyntaxParser, CData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -84,15 +83,14 @@ TEST(CFDE_XMLSyntaxParser, CDataWithInnerScript) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -131,15 +129,14 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangArrow) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -174,15 +171,14 @@ TEST(CFDE_XMLSyntaxParser, ArrowBangBracketArrow) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -211,15 +207,14 @@ TEST(CFDE_XMLSyntaxParser, IncompleteCData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -248,15 +243,14 @@ TEST(CFDE_XMLSyntaxParser, UnClosedCData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -285,15 +279,14 @@ TEST(CFDE_XMLSyntaxParser, EmptyCData) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -332,15 +325,14 @@ TEST(CFDE_XMLSyntaxParser, Comment) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -375,15 +367,14 @@ TEST(CFDE_XMLSyntaxParser, IncorrectCommentStart) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -418,15 +409,14 @@ TEST(CFDE_XMLSyntaxParser, CommentEmpty) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -461,15 +451,14 @@ TEST(CFDE_XMLSyntaxParser, CommentThreeDash) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -496,15 +485,14 @@ TEST(CFDE_XMLSyntaxParser, CommentTwoDash) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -535,15 +523,14 @@ TEST(CFDE_XMLSyntaxParser, Entities) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -575,15 +562,14 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowHex) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
@@ -615,15 +601,14 @@ TEST(CFDE_XMLSyntaxParser, EntityOverflowDecimal) {
// We * sizeof(FX_WCHAR) because we pass in the uint8_t, not the FX_WCHAR.
size_t len = FXSYS_wcslen(input) * sizeof(FX_WCHAR);
- std::unique_ptr<IFGAS_Stream> stream(IFGAS_Stream::CreateStream(
- reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0));
+ CFX_RetainPtr<IFGAS_Stream> stream = IFGAS_Stream::CreateStream(
+ reinterpret_cast<uint8_t*>(const_cast<FX_WCHAR*>(input)), len, 0);
CFDE_XMLSyntaxParser parser;
- parser.Init(stream.get(), 256);
-
- CFX_WideString data;
-
+ parser.Init(stream, 256);
EXPECT_EQ(FDE_XmlSyntaxResult::ElementOpen, parser.DoSyntaxParse());
EXPECT_EQ(FDE_XmlSyntaxResult::TagName, parser.DoSyntaxParse());
+
+ CFX_WideString data;
parser.GetTagName(data);
EXPECT_EQ(L"script", data);
diff --git a/xfa/fgas/crt/fgas_stream.cpp b/xfa/fgas/crt/fgas_stream.cpp
index 3ccb652141..966f615676 100644
--- a/xfa/fgas/crt/fgas_stream.cpp
+++ b/xfa/fgas/crt/fgas_stream.cpp
@@ -208,8 +208,6 @@ class CFGAS_Stream : public IFGAS_Stream {
uint32_t dwAccess);
// IFGAS_Stream
- void Release() override;
- IFGAS_Stream* Retain() override;
uint32_t GetAccessModes() const override;
int32_t GetLength() const override;
int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) override;
@@ -224,9 +222,9 @@ class CFGAS_Stream : public IFGAS_Stream {
int32_t GetBOM(uint8_t bom[4]) const override;
uint16_t GetCodePage() const override;
uint16_t SetCodePage(uint16_t wCodePage) override;
- IFGAS_Stream* CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) override;
+ CFX_RetainPtr<IFGAS_Stream> CreateSharedStream(uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) override;
protected:
FX_STREAMTYPE m_eStreamType;
@@ -241,12 +239,10 @@ class CFGAS_Stream : public IFGAS_Stream {
class CFGAS_TextStream : public IFGAS_Stream {
public:
- CFGAS_TextStream(IFGAS_Stream* pStream, bool bDelStream);
+ explicit CFGAS_TextStream(const CFX_RetainPtr<IFGAS_Stream>& pStream);
~CFGAS_TextStream() override;
// IFGAS_Stream
- void Release() override;
- IFGAS_Stream* Retain() override;
uint32_t GetAccessModes() const override;
int32_t GetLength() const override;
int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) override;
@@ -261,26 +257,27 @@ class CFGAS_TextStream : public IFGAS_Stream {
int32_t GetBOM(uint8_t bom[4]) const override;
uint16_t GetCodePage() const override;
uint16_t SetCodePage(uint16_t wCodePage) override;
- IFGAS_Stream* CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) override;
+ CFX_RetainPtr<IFGAS_Stream> CreateSharedStream(uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) override;
protected:
+ void InitStream();
+
uint16_t m_wCodePage;
int32_t m_wBOMLength;
uint32_t m_dwBOM;
uint8_t* m_pBuf;
int32_t m_iBufSize;
- bool m_bDelStream;
- IFGAS_Stream* m_pStreamImp;
- int32_t m_iRefCount;
- void InitStream();
+ CFX_RetainPtr<IFGAS_Stream> m_pStreamImp;
};
class CFGAS_FileRead : public IFX_SeekableReadStream {
public:
- static CFX_RetainPtr<CFGAS_FileRead> Create(IFGAS_Stream* pStream,
- bool bReleaseStream);
+ static CFX_RetainPtr<CFGAS_FileRead> Create(
+ const CFX_RetainPtr<IFGAS_Stream>& pStream);
+
+ explicit CFGAS_FileRead(const CFX_RetainPtr<IFGAS_Stream>& pStream);
~CFGAS_FileRead() override;
// IFX_SeekableReadStream
@@ -288,10 +285,7 @@ class CFGAS_FileRead : public IFX_SeekableReadStream {
bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
protected:
- CFGAS_FileRead(IFGAS_Stream* pStream, bool bReleaseStream);
-
- bool m_bReleaseStream;
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
};
int32_t FileLength(FXSYS_FILE* file) {
@@ -326,46 +320,43 @@ bool FileSetSize(FXSYS_FILE* file, int32_t size) {
} // namespace
// static
-IFGAS_Stream* IFGAS_Stream::CreateStream(
+CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateStream(
const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
uint32_t dwAccess) {
- CFGAS_Stream* pSR = new CFGAS_Stream;
- if (!pSR->LoadFileRead(pFileRead, dwAccess)) {
- pSR->Release();
+ auto pSR = pdfium::MakeRetain<CFGAS_Stream>();
+ if (!pSR->LoadFileRead(pFileRead, dwAccess))
return nullptr;
- }
+
if (dwAccess & FX_STREAMACCESS_Text)
- return new CFGAS_TextStream(pSR, true);
+ return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
return pSR;
}
// static
-IFGAS_Stream* IFGAS_Stream::CreateStream(
+CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateStream(
const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite,
uint32_t dwAccess) {
- CFGAS_Stream* pSR = new CFGAS_Stream;
- if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) {
- pSR->Release();
+ auto pSR = pdfium::MakeRetain<CFGAS_Stream>();
+ if (!pSR->LoadFileWrite(pFileWrite, dwAccess))
return nullptr;
- }
+
if (dwAccess & FX_STREAMACCESS_Text)
- return new CFGAS_TextStream(pSR, true);
+ return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
return pSR;
}
// static
-IFGAS_Stream* IFGAS_Stream::CreateStream(uint8_t* pData,
- int32_t length,
- uint32_t dwAccess) {
- CFGAS_Stream* pSR = new CFGAS_Stream;
- if (!pSR->LoadBuffer(pData, length, dwAccess)) {
- pSR->Release();
+CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateStream(uint8_t* pData,
+ int32_t length,
+ uint32_t dwAccess) {
+ auto pSR = pdfium::MakeRetain<CFGAS_Stream>();
+ if (!pSR->LoadBuffer(pData, length, dwAccess))
return nullptr;
- }
+
if (dwAccess & FX_STREAMACCESS_Text)
- return new CFGAS_TextStream(pSR, true);
+ return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
return pSR;
}
@@ -905,30 +896,24 @@ int32_t CFGAS_BufferStreamImp::WriteString(const FX_WCHAR* pStr,
}
// static
-IFGAS_Stream* IFGAS_Stream::CreateTextStream(IFGAS_Stream* pBaseStream,
- bool bDeleteOnRelease) {
+CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateTextStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pBaseStream) {
ASSERT(pBaseStream);
- return new CFGAS_TextStream(pBaseStream, bDeleteOnRelease);
+ return pdfium::MakeRetain<CFGAS_TextStream>(pBaseStream);
}
-CFGAS_TextStream::CFGAS_TextStream(IFGAS_Stream* pStream, bool bDelStream)
+CFGAS_TextStream::CFGAS_TextStream(const CFX_RetainPtr<IFGAS_Stream>& pStream)
: m_wCodePage(FX_CODEPAGE_DefANSI),
m_wBOMLength(0),
m_dwBOM(0),
m_pBuf(nullptr),
m_iBufSize(0),
- m_bDelStream(bDelStream),
- m_pStreamImp(pStream),
- m_iRefCount(1) {
+ m_pStreamImp(pStream) {
ASSERT(m_pStreamImp);
- m_pStreamImp->Retain();
InitStream();
}
CFGAS_TextStream::~CFGAS_TextStream() {
- m_pStreamImp->Release();
- if (m_bDelStream)
- m_pStreamImp->Release();
if (m_pBuf)
FX_Free(m_pBuf);
}
@@ -979,16 +964,6 @@ void CFGAS_TextStream::InitStream() {
m_pStreamImp->Seek(FX_STREAMSEEK_Begin, std::max(m_wBOMLength, iPosition));
}
-void CFGAS_TextStream::Release() {
- if (--m_iRefCount < 1)
- delete this;
-}
-
-IFGAS_Stream* CFGAS_TextStream::Retain() {
- m_iRefCount++;
- return this;
-}
-
uint32_t CFGAS_TextStream::GetAccessModes() const {
return m_pStreamImp->GetAccessModes() | FX_STREAMACCESS_Text;
}
@@ -1030,16 +1005,17 @@ uint16_t CFGAS_TextStream::GetCodePage() const {
return m_wCodePage;
}
-IFGAS_Stream* CFGAS_TextStream::CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) {
- IFGAS_Stream* pSR =
+CFX_RetainPtr<IFGAS_Stream> CFGAS_TextStream::CreateSharedStream(
+ uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) {
+ CFX_RetainPtr<IFGAS_Stream> pSR =
m_pStreamImp->CreateSharedStream(dwAccess, iOffset, iLength);
if (!pSR)
return nullptr;
if (dwAccess & FX_STREAMACCESS_Text)
- return new CFGAS_TextStream(pSR, true);
+ return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
return pSR;
}
@@ -1246,16 +1222,6 @@ bool CFGAS_Stream::LoadBufferRead(
return true;
}
-void CFGAS_Stream::Release() {
- if (--m_iRefCount < 1) {
- delete this;
- }
-}
-IFGAS_Stream* CFGAS_Stream::Retain() {
- m_iRefCount++;
- return this;
-}
-
uint32_t CFGAS_Stream::GetAccessModes() const {
return m_dwAccess;
}
@@ -1445,9 +1411,10 @@ uint16_t CFGAS_Stream::SetCodePage(uint16_t wCodePage) {
return FX_CODEPAGE_UTF16BE;
#endif
}
-IFGAS_Stream* CFGAS_Stream::CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) {
+
+CFX_RetainPtr<IFGAS_Stream> CFGAS_Stream::CreateSharedStream(uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) {
ASSERT(iLength > 0);
if (!m_pStreamImp)
return nullptr;
@@ -1469,7 +1436,7 @@ IFGAS_Stream* CFGAS_Stream::CreateSharedStream(uint32_t dwAccess,
if (iEnd < iStart || iEnd > iTotal)
return nullptr;
- CFGAS_Stream* pShared = new CFGAS_Stream;
+ auto pShared = pdfium::MakeRetain<CFGAS_Stream>();
pShared->m_eStreamType = FX_STREAMTYPE_Stream;
pShared->m_pStreamImp = m_pStreamImp;
pShared->m_dwAccess = dwAccess;
@@ -1478,31 +1445,27 @@ IFGAS_Stream* CFGAS_Stream::CreateSharedStream(uint32_t dwAccess,
pShared->m_iStart = iStart;
pShared->m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iLength;
if (dwAccess & FX_STREAMACCESS_Text)
- return IFGAS_Stream::CreateTextStream(pShared, true);
+ return IFGAS_Stream::CreateTextStream(pShared);
return pShared;
}
CFX_RetainPtr<IFX_SeekableReadStream> IFGAS_Stream::MakeSeekableReadStream() {
- return CFGAS_FileRead::Create(this, false);
+ return CFGAS_FileRead::Create(CFX_RetainPtr<IFGAS_Stream>(this));
}
-CFX_RetainPtr<CFGAS_FileRead> CFGAS_FileRead::Create(IFGAS_Stream* pStream,
- bool bReleaseStream) {
- return CFX_RetainPtr<CFGAS_FileRead>(
- new CFGAS_FileRead(pStream, bReleaseStream));
+CFX_RetainPtr<CFGAS_FileRead> CFGAS_FileRead::Create(
+ const CFX_RetainPtr<IFGAS_Stream>& pStream) {
+ return pdfium::MakeRetain<CFGAS_FileRead>(pStream);
}
-CFGAS_FileRead::CFGAS_FileRead(IFGAS_Stream* pStream, bool bReleaseStream)
- : m_bReleaseStream(bReleaseStream), m_pStream(pStream) {
+CFGAS_FileRead::CFGAS_FileRead(const CFX_RetainPtr<IFGAS_Stream>& pStream)
+ : m_pStream(pStream) {
ASSERT(m_pStream);
}
-CFGAS_FileRead::~CFGAS_FileRead() {
- if (m_bReleaseStream) {
- m_pStream->Release();
- }
-}
+CFGAS_FileRead::~CFGAS_FileRead() {}
+
FX_FILESIZE CFGAS_FileRead::GetSize() {
return (FX_FILESIZE)m_pStream->GetLength();
}
diff --git a/xfa/fgas/crt/fgas_stream.h b/xfa/fgas/crt/fgas_stream.h
index b6552d9825..79fda58d2a 100644
--- a/xfa/fgas/crt/fgas_stream.h
+++ b/xfa/fgas/crt/fgas_stream.h
@@ -27,27 +27,23 @@ enum FX_STREAMSEEK {
FX_STREAMSEEK_End,
};
-class IFGAS_Stream {
+class IFGAS_Stream : public CFX_Retainable {
public:
- static IFGAS_Stream* CreateStream(
+ static CFX_RetainPtr<IFGAS_Stream> CreateStream(
const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
uint32_t dwAccess);
- static IFGAS_Stream* CreateStream(
+ static CFX_RetainPtr<IFGAS_Stream> CreateStream(
const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite,
uint32_t dwAccess);
- static IFGAS_Stream* CreateStream(uint8_t* pData,
- int32_t length,
- uint32_t dwAccess);
- static IFGAS_Stream* CreateTextStream(IFGAS_Stream* pBaseStream,
- bool bDeleteOnRelease);
+ static CFX_RetainPtr<IFGAS_Stream> CreateStream(uint8_t* pData,
+ int32_t length,
+ uint32_t dwAccess);
+ static CFX_RetainPtr<IFGAS_Stream> CreateTextStream(
+ const CFX_RetainPtr<IFGAS_Stream>& pBaseStream);
- virtual ~IFGAS_Stream() {}
- virtual void Release() = 0;
- virtual IFGAS_Stream* Retain() = 0;
-
- virtual IFGAS_Stream* CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) = 0;
+ virtual CFX_RetainPtr<IFGAS_Stream> CreateSharedStream(uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) = 0;
virtual uint32_t GetAccessModes() const = 0;
virtual int32_t GetLength() const = 0;
diff --git a/xfa/fgas/font/cfgas_gefont.cpp b/xfa/fgas/font/cfgas_gefont.cpp
index 3bca4dc09f..bc971f6294 100644
--- a/xfa/fgas/font/cfgas_gefont.cpp
+++ b/xfa/fgas/font/cfgas_gefont.cpp
@@ -72,9 +72,10 @@ CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer,
}
// static
-CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFGAS_Stream* pFontStream,
- CFGAS_FontMgr* pFontMgr,
- bool bSaveStream) {
+CFGAS_GEFont* CFGAS_GEFont::LoadFont(
+ const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ CFGAS_FontMgr* pFontMgr,
+ bool bSaveStream) {
CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) {
pFont->Release();
@@ -203,12 +204,13 @@ bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
return InitFont();
}
-bool CFGAS_GEFont::LoadFontInternal(IFGAS_Stream* pFontStream,
- bool bSaveStream) {
+bool CFGAS_GEFont::LoadFontInternal(
+ const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ bool bSaveStream) {
if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1)
return false;
if (bSaveStream)
- m_pStream.reset(pFontStream);
+ m_pStream = pFontStream;
m_pFileRead = pFontStream->MakeSeekableReadStream();
m_pFont = new CFX_Font;
diff --git a/xfa/fgas/font/cfgas_gefont.h b/xfa/fgas/font/cfgas_gefont.h
index b4fcf25ae1..86e5e4c955 100644
--- a/xfa/fgas/font/cfgas_gefont.h
+++ b/xfa/fgas/font/cfgas_gefont.h
@@ -33,7 +33,7 @@ class CFGAS_GEFont {
static CFGAS_GEFont* LoadFont(const uint8_t* pBuffer,
int32_t iLength,
CFGAS_FontMgr* pFontMgr);
- static CFGAS_GEFont* LoadFont(IFGAS_Stream* pFontStream,
+ static CFGAS_GEFont* LoadFont(const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
CFGAS_FontMgr* pFontMgr,
bool bSaveStream);
#endif
@@ -69,7 +69,8 @@ class CFGAS_GEFont {
uint32_t dwFontStyles,
uint16_t wCodePage);
bool LoadFontInternal(const uint8_t* pBuffer, int32_t length);
- bool LoadFontInternal(IFGAS_Stream* pFontStream, bool bSaveStream);
+ bool LoadFontInternal(const CFX_RetainPtr<IFGAS_Stream>& pFontStream,
+ bool bSaveStream);
#endif
bool LoadFontInternal(CFX_Font* pExternalFont);
bool LoadFontInternal(std::unique_ptr<CFX_Font> pInternalFont);
@@ -97,7 +98,7 @@ class CFGAS_GEFont {
CFGAS_FontMgr* const m_pFontMgr;
int32_t m_iRefCount;
bool m_bExternalFont;
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
std::unique_ptr<CFX_UnicodeEncoding> m_pFontEncoding;
std::unique_ptr<CFX_DiscreteArrayTemplate<uint16_t>> m_pCharWidthMap;
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.cpp b/xfa/fxfa/parser/cxfa_dataexporter.cpp
index 9760261baf..a9965f52a5 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.cpp
+++ b/xfa/fxfa/parser/cxfa_dataexporter.cpp
@@ -201,7 +201,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
IFX_MemoryStream::Create(true);
// Note: ambiguous without cast below.
- IFGAS_Stream* pTempStream = IFGAS_Stream::CreateStream(
+ CFX_RetainPtr<IFGAS_Stream> pTempStream = IFGAS_Stream::CreateStream(
CFX_RetainPtr<IFX_SeekableWriteStream>(pMemStream),
FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
FX_STREAMACCESS_Append);
@@ -210,7 +210,6 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
pRichTextXML->SaveXMLNode(pTempStream);
wsChildren += CFX_WideString::FromUTF8(
CFX_ByteStringC(pMemStream->GetBuffer(), pMemStream->GetSize()));
- pTempStream->Release();
} else if (pRawValueNode->GetElementType() == XFA_Element::Sharpxml &&
wsContentType == FX_WSTRC(L"text/xml")) {
CFX_WideString wsRawValue;
@@ -320,7 +319,7 @@ void RegenerateFormFile_Changed(CXFA_Node* pNode,
}
void RegenerateFormFile_Container(CXFA_Node* pNode,
- IFGAS_Stream* pStream,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
bool bSaveXML = false) {
XFA_Element eType = pNode->GetElementType();
if (eType == XFA_Element::Field || eType == XFA_Element::Draw ||
@@ -373,10 +372,11 @@ void RegenerateFormFile_Container(CXFA_Node* pNode,
} // namespace
-void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode,
- IFGAS_Stream* pStream,
- const FX_CHAR* pChecksum,
- bool bSaveXML) {
+void XFA_DataExporter_RegenerateFormFile(
+ CXFA_Node* pNode,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ const FX_CHAR* pChecksum,
+ bool bSaveXML) {
if (pNode->IsModelNode()) {
static const FX_WCHAR s_pwsTagName[] = L"<form";
static const FX_WCHAR s_pwsClose[] = L"</form\n>";
@@ -461,19 +461,17 @@ bool CXFA_DataExporter::Export(
if (!pWrite)
return false;
- IFGAS_Stream* pStream = IFGAS_Stream::CreateStream(
+ CFX_RetainPtr<IFGAS_Stream> pStream = IFGAS_Stream::CreateStream(
pWrite,
FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
if (!pStream)
return false;
pStream->SetCodePage(FX_CODEPAGE_UTF8);
- bool bRet = Export(pStream, pNode, dwFlag, pChecksum);
- pStream->Release();
- return bRet;
+ return Export(pStream, pNode, dwFlag, pChecksum);
}
-bool CXFA_DataExporter::Export(IFGAS_Stream* pStream,
+bool CXFA_DataExporter::Export(const CFX_RetainPtr<IFGAS_Stream>& pStream,
CXFA_Node* pNode,
uint32_t dwFlag,
const FX_CHAR* pChecksum) {
diff --git a/xfa/fxfa/parser/cxfa_dataexporter.h b/xfa/fxfa/parser/cxfa_dataexporter.h
index f3c784a86a..0e5de00796 100644
--- a/xfa/fxfa/parser/cxfa_dataexporter.h
+++ b/xfa/fxfa/parser/cxfa_dataexporter.h
@@ -26,7 +26,7 @@ class CXFA_DataExporter {
const FX_CHAR* pChecksum);
protected:
- bool Export(IFGAS_Stream* pStream,
+ bool Export(const CFX_RetainPtr<IFGAS_Stream>& pStream,
CXFA_Node* pNode,
uint32_t dwFlag,
const FX_CHAR* pChecksum);
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 5dd6c52717..f3f79cbbec 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1445,11 +1445,9 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
IFX_MemoryStream::Create(true);
// Note: ambiguious below without static_cast.
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> pStream(
- IFGAS_Stream::CreateStream(
- CFX_RetainPtr<IFX_SeekableWriteStream>(pMemoryStream),
- FX_STREAMACCESS_Text | FX_STREAMACCESS_Write |
- FX_STREAMACCESS_Append));
+ CFX_RetainPtr<IFGAS_Stream> pStream = IFGAS_Stream::CreateStream(
+ CFX_RetainPtr<IFX_SeekableWriteStream>(pMemoryStream),
+ FX_STREAMACCESS_Text | FX_STREAMACCESS_Write | FX_STREAMACCESS_Append);
if (!pStream) {
pArguments->GetReturnValue()->SetString(bsXMLHeader);
@@ -1458,9 +1456,9 @@ void CXFA_Node::Script_NodeClass_SaveXML(CFXJSE_Arguments* pArguments) {
pStream->SetCodePage(FX_CODEPAGE_UTF8);
pStream->WriteData(bsXMLHeader.raw_str(), bsXMLHeader.GetLength());
if (GetPacketID() == XFA_XDPPACKET_Form)
- XFA_DataExporter_RegenerateFormFile(this, pStream.get(), nullptr, true);
+ XFA_DataExporter_RegenerateFormFile(this, pStream, nullptr, true);
else
- pElement->SaveXMLNode(pStream.get());
+ pElement->SaveXMLNode(pStream);
// TODO(weili): Check whether we need to save pretty print XML, pdfium:501.
// For now, just put it here to avoid unused variable warning.
(void)bPrettyMode;
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.cpp b/xfa/fxfa/parser/cxfa_simple_parser.cpp
index 2329e86874..9eca652db7 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_simple_parser.cpp
@@ -7,6 +7,7 @@
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
#include "core/fxcrt/fx_ext.h"
+#include "third_party/base/ptr_util.h"
#include "xfa/fgas/crt/fgas_codepage.h"
#include "xfa/fxfa/fxfa.h"
#include "xfa/fxfa/parser/cxfa_document.h"
@@ -282,8 +283,8 @@ int32_t CXFA_SimpleParser::StartParse(
XFA_XDPPACKET ePacketID) {
CloseParser();
m_pFileRead = pStream;
- m_pStream.reset(IFGAS_Stream::CreateStream(
- pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text));
+ m_pStream = IFGAS_Stream::CreateStream(
+ pStream, FX_STREAMACCESS_Read | FX_STREAMACCESS_Text);
if (!m_pStream)
return XFA_PARSESTATUS_StreamErr;
@@ -293,7 +294,7 @@ int32_t CXFA_SimpleParser::StartParse(
m_pStream->SetCodePage(FX_CODEPAGE_UTF8);
}
m_pXMLDoc.reset(new CFDE_XMLDoc);
- m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream.get());
+ m_pXMLParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), m_pStream);
if (!m_pXMLDoc->LoadXML(m_pXMLParser))
return XFA_PARSESTATUS_StatusErr;
@@ -313,10 +314,10 @@ int32_t CXFA_SimpleParser::DoParse(IFX_Pause* pPause) {
m_pRootNode = ParseAsXDPPacket(GetDocumentNode(m_pXMLDoc.get()), m_ePacketID);
m_pXMLDoc->CloseXML();
- m_pStream.reset();
-
+ m_pStream.Reset();
if (!m_pRootNode)
return XFA_PARSESTATUS_StatusErr;
+
return XFA_PARSESTATUS_Done;
}
@@ -326,10 +327,9 @@ int32_t CXFA_SimpleParser::ParseXMLData(const CFX_WideString& wsXML,
CloseParser();
pXMLNode = nullptr;
- std::unique_ptr<IFGAS_Stream> pStream(new CXFA_WideTextRead(wsXML));
- m_pXMLDoc.reset(new CFDE_XMLDoc);
- CXFA_XMLParser* pParser =
- new CXFA_XMLParser(m_pXMLDoc->GetRoot(), pStream.get());
+ auto pStream = pdfium::MakeRetain<CXFA_WideTextRead>(wsXML);
+ m_pXMLDoc = pdfium::MakeUnique<CFDE_XMLDoc>();
+ CXFA_XMLParser* pParser = new CXFA_XMLParser(m_pXMLDoc->GetRoot(), pStream);
pParser->m_dwCheckStatus = 0x03;
if (!m_pXMLDoc->LoadXML(pParser))
return XFA_PARSESTATUS_StatusErr;
@@ -1306,5 +1306,5 @@ void CXFA_SimpleParser::ParseInstruction(CXFA_Node* pXFANode,
void CXFA_SimpleParser::CloseParser() {
m_pXMLDoc.reset();
- m_pStream.reset();
+ m_pStream.Reset();
}
diff --git a/xfa/fxfa/parser/cxfa_simple_parser.h b/xfa/fxfa/parser/cxfa_simple_parser.h
index 559df7124b..5f61ad7d28 100644
--- a/xfa/fxfa/parser/cxfa_simple_parser.h
+++ b/xfa/fxfa/parser/cxfa_simple_parser.h
@@ -78,7 +78,7 @@ class CXFA_SimpleParser {
CXFA_XMLParser* m_pXMLParser;
std::unique_ptr<CFDE_XMLDoc> m_pXMLDoc;
- std::unique_ptr<IFGAS_Stream, ReleaseDeleter<IFGAS_Stream>> m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
CFX_RetainPtr<IFX_SeekableReadStream> m_pFileRead;
CXFA_Document* m_pFactory;
CXFA_Node* m_pRootNode;
diff --git a/xfa/fxfa/parser/cxfa_widetextread.cpp b/xfa/fxfa/parser/cxfa_widetextread.cpp
index cf03a09e7c..54442df7c0 100644
--- a/xfa/fxfa/parser/cxfa_widetextread.cpp
+++ b/xfa/fxfa/parser/cxfa_widetextread.cpp
@@ -12,17 +12,7 @@
#include "xfa/fgas/crt/fgas_codepage.h"
CXFA_WideTextRead::CXFA_WideTextRead(const CFX_WideString& wsBuffer)
- : m_wsBuffer(wsBuffer), m_iPosition(0), m_iRefCount(1) {}
-
-void CXFA_WideTextRead::Release() {
- if (--m_iRefCount < 1)
- delete this;
-}
-
-IFGAS_Stream* CXFA_WideTextRead::Retain() {
- m_iRefCount++;
- return this;
-}
+ : m_wsBuffer(wsBuffer), m_iPosition(0) {}
uint32_t CXFA_WideTextRead::GetAccessModes() const {
return FX_STREAMACCESS_Read | FX_STREAMACCESS_Text;
@@ -98,9 +88,10 @@ uint16_t CXFA_WideTextRead::SetCodePage(uint16_t wCodePage) {
return GetCodePage();
}
-IFGAS_Stream* CXFA_WideTextRead::CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) {
+CFX_RetainPtr<IFGAS_Stream> CXFA_WideTextRead::CreateSharedStream(
+ uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) {
return nullptr;
}
diff --git a/xfa/fxfa/parser/cxfa_widetextread.h b/xfa/fxfa/parser/cxfa_widetextread.h
index bea3ab8fba..d3d3b3792a 100644
--- a/xfa/fxfa/parser/cxfa_widetextread.h
+++ b/xfa/fxfa/parser/cxfa_widetextread.h
@@ -14,8 +14,6 @@ class CXFA_WideTextRead : public IFGAS_Stream {
explicit CXFA_WideTextRead(const CFX_WideString& wsBuffer);
// IFGAS_Stream
- void Release() override;
- IFGAS_Stream* Retain() override;
uint32_t GetAccessModes() const override;
int32_t GetLength() const override;
int32_t Seek(FX_STREAMSEEK eSeek, int32_t iOffset) override;
@@ -30,16 +28,15 @@ class CXFA_WideTextRead : public IFGAS_Stream {
int32_t GetBOM(uint8_t bom[4]) const override;
uint16_t GetCodePage() const override;
uint16_t SetCodePage(uint16_t wCodePage) override;
- IFGAS_Stream* CreateSharedStream(uint32_t dwAccess,
- int32_t iOffset,
- int32_t iLength) override;
+ CFX_RetainPtr<IFGAS_Stream> CreateSharedStream(uint32_t dwAccess,
+ int32_t iOffset,
+ int32_t iLength) override;
CFX_WideString GetSrcText() const;
protected:
CFX_WideString m_wsBuffer;
int32_t m_iPosition;
- int32_t m_iRefCount;
};
#endif // XFA_FXFA_PARSER_CXFA_WIDETEXTREAD_H_
diff --git a/xfa/fxfa/parser/cxfa_xml_parser.cpp b/xfa/fxfa/parser/cxfa_xml_parser.cpp
index ac378f0b95..6d2ef350d9 100644
--- a/xfa/fxfa/parser/cxfa_xml_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_xml_parser.cpp
@@ -6,7 +6,8 @@
#include "xfa/fxfa/parser/cxfa_xml_parser.h"
-CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot, IFGAS_Stream* pStream)
+CXFA_XMLParser::CXFA_XMLParser(CFDE_XMLNode* pRoot,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream)
: m_nElementStart(0),
m_dwCheckStatus(0),
m_dwCurrentCheckStatus(0),
diff --git a/xfa/fxfa/parser/cxfa_xml_parser.h b/xfa/fxfa/parser/cxfa_xml_parser.h
index cff279453d..4c64ee2f8c 100644
--- a/xfa/fxfa/parser/cxfa_xml_parser.h
+++ b/xfa/fxfa/parser/cxfa_xml_parser.h
@@ -16,7 +16,8 @@ class IFX_Pause;
class CXFA_XMLParser : public CFDE_XMLParser {
public:
- CXFA_XMLParser(CFDE_XMLNode* pRoot, IFGAS_Stream* pStream);
+ CXFA_XMLParser(CFDE_XMLNode* pRoot,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream);
~CXFA_XMLParser() override;
// CFDE_XMLParser
@@ -31,7 +32,7 @@ class CXFA_XMLParser : public CFDE_XMLParser {
protected:
CFDE_XMLNode* m_pRoot;
- IFGAS_Stream* m_pStream;
+ CFX_RetainPtr<IFGAS_Stream> m_pStream;
std::unique_ptr<CFDE_XMLSyntaxParser, ReleaseDeleter<CFDE_XMLSyntaxParser>>
m_pParser;
CFDE_XMLNode* m_pParent;
diff --git a/xfa/fxfa/parser/xfa_utils.h b/xfa/fxfa/parser/xfa_utils.h
index 961c0a4189..d09afda0f9 100644
--- a/xfa/fxfa/parser/xfa_utils.h
+++ b/xfa/fxfa/parser/xfa_utils.h
@@ -172,10 +172,11 @@ void XFA_GetPlainTextFromRichText(CFDE_XMLNode* pXMLNode,
bool XFA_FieldIsMultiListBox(CXFA_Node* pFieldNode);
void XFA_DataExporter_DealWithDataGroupNode(CXFA_Node* pDataNode);
-void XFA_DataExporter_RegenerateFormFile(CXFA_Node* pNode,
- IFGAS_Stream* pStream,
- const FX_CHAR* pChecksum = nullptr,
- bool bSaveXML = false);
+void XFA_DataExporter_RegenerateFormFile(
+ CXFA_Node* pNode,
+ const CFX_RetainPtr<IFGAS_Stream>& pStream,
+ const FX_CHAR* pChecksum = nullptr,
+ bool bSaveXML = false);
const XFA_NOTSUREATTRIBUTE* XFA_GetNotsureAttribute(
XFA_Element eElement,