summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_document_parser.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp23
-rw-r--r--xfa/fxfa/parser/cxfa_xmllocale.cpp4
3 files changed, 15 insertions, 18 deletions
diff --git a/xfa/fxfa/parser/cxfa_document_parser.cpp b/xfa/fxfa/parser/cxfa_document_parser.cpp
index 96c031079b..5cb08863c8 100644
--- a/xfa/fxfa/parser/cxfa_document_parser.cpp
+++ b/xfa/fxfa/parser/cxfa_document_parser.cpp
@@ -10,7 +10,7 @@
#include <vector>
#include "core/fxcrt/autorestorer.h"
-#include "core/fxcrt/cfx_memorystream.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/cfx_widetextbuf.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
@@ -332,8 +332,8 @@ bool CXFA_DocumentParser::Parse(
}
CFX_XMLNode* CXFA_DocumentParser::ParseXMLData(const ByteString& wsXML) {
- auto pStream = pdfium::MakeRetain<CFX_MemoryStream>(
- const_cast<uint8_t*>(wsXML.raw_str()), wsXML.GetLength(), false);
+ auto pStream = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
+ wsXML.raw_str(), wsXML.GetLength());
xml_doc_ = LoadXML(pStream);
if (!xml_doc_)
return nullptr;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 8babe45ef3..06bbb0936a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -15,7 +15,7 @@
#include "core/fxcrt/autorestorer.h"
#include "core/fxcrt/cfx_decimal.h"
-#include "core/fxcrt/cfx_memorystream.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/fx_extension.h"
#include "core/fxcrt/locale_iface.h"
@@ -200,24 +200,22 @@ RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
FXCODEC_IMAGE_TYPE type = XFA_GetImageType(pImage->GetContentType());
ByteString bsContent;
- uint8_t* pImageBuffer = nullptr;
+ std::vector<uint8_t> buffer;
RetainPtr<IFX_SeekableReadStream> pImageFileRead;
if (wsImage.GetLength() > 0) {
XFA_AttributeEnum iEncoding = pImage->GetTransferEncoding();
if (iEncoding == XFA_AttributeEnum::Base64) {
ByteString bsData = wsImage.UTF8Encode();
- int32_t iLength = bsData.GetLength();
- pImageBuffer = FX_Alloc(uint8_t, iLength);
- int32_t iRead = XFA_Base64Decode(bsData.c_str(), pImageBuffer);
+ buffer.resize(bsData.GetLength());
+ int32_t iRead = XFA_Base64Decode(bsData.c_str(), buffer.data());
if (iRead > 0) {
pImageFileRead =
- pdfium::MakeRetain<CFX_MemoryStream>(pImageBuffer, iRead, false);
+ pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(buffer.data(), iRead);
}
} else {
bsContent = wsImage.ToDefANSI();
- pImageFileRead = pdfium::MakeRetain<CFX_MemoryStream>(
- const_cast<uint8_t*>(bsContent.raw_str()), bsContent.GetLength(),
- false);
+ pImageFileRead = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
+ bsContent.raw_str(), bsContent.GetLength());
}
} else {
WideString wsURL = wsHref;
@@ -231,16 +229,15 @@ RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc,
}
pImageFileRead = pDoc->GetDocEnvironment()->OpenLinkedFile(pDoc, wsURL);
}
- if (!pImageFileRead) {
- FX_Free(pImageBuffer);
+ if (!pImageFileRead)
return nullptr;
- }
+
bNameImage = false;
RetainPtr<CFX_DIBitmap> pBitmap =
XFA_LoadImageFromBuffer(pImageFileRead, type, iImageXDpi, iImageYDpi);
- FX_Free(pImageBuffer);
return pBitmap;
}
+
bool SplitDateTime(const WideString& wsDateTime,
WideString& wsDate,
WideString& wsTime) {
diff --git a/xfa/fxfa/parser/cxfa_xmllocale.cpp b/xfa/fxfa/parser/cxfa_xmllocale.cpp
index e4858e907e..2806a084d6 100644
--- a/xfa/fxfa/parser/cxfa_xmllocale.cpp
+++ b/xfa/fxfa/parser/cxfa_xmllocale.cpp
@@ -8,7 +8,7 @@
#include <utility>
-#include "core/fxcrt/cfx_memorystream.h"
+#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/fx_codepage.h"
#include "core/fxcrt/xml/cfx_xmldocument.h"
#include "core/fxcrt/xml/cfx_xmlelement.h"
@@ -32,7 +32,7 @@ constexpr wchar_t kCurrencySymbol[] = L"currencySymbol";
std::unique_ptr<CXFA_XMLLocale> CXFA_XMLLocale::Create(
pdfium::span<uint8_t> data) {
auto stream =
- pdfium::MakeRetain<CFX_MemoryStream>(data.data(), data.size(), false);
+ pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(data.data(), data.size());
CFX_XMLParser parser(stream);
auto doc = parser.Parse();
if (!doc)