summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/parser')
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_stream_acc.h4
3 files changed, 8 insertions, 6 deletions
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index 7a54fcf8ff..de69bfae7b 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -91,7 +91,7 @@ std::unique_ptr<CPDF_Object> CPDF_Stream::CloneNonCyclic(
pNewDict = ToDictionary(
static_cast<CPDF_Object*>(pDict)->CloneNonCyclic(bDirect, pVisited));
}
- return pdfium::MakeUnique<CPDF_Stream>(acc.DetachData(), streamSize,
+ return pdfium::MakeUnique<CPDF_Stream>(acc.DetachData().release(), streamSize,
std::move(pNewDict));
}
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.cpp b/core/fpdfapi/parser/cpdf_stream_acc.cpp
index 01d8e148df..423de7c571 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.cpp
+++ b/core/fpdfapi/parser/cpdf_stream_acc.cpp
@@ -74,14 +74,14 @@ uint32_t CPDF_StreamAcc::GetSize() const {
return m_pStream ? m_pStream->GetRawSize() : 0;
}
-uint8_t* CPDF_StreamAcc::DetachData() {
+std::unique_ptr<uint8_t, FxFreeDeleter> CPDF_StreamAcc::DetachData() {
if (m_bNewBuf) {
- uint8_t* p = m_pData;
+ std::unique_ptr<uint8_t, FxFreeDeleter> p(m_pData);
m_pData = nullptr;
m_dwSize = 0;
return p;
}
- uint8_t* p = FX_Alloc(uint8_t, m_dwSize);
- FXSYS_memcpy(p, m_pData, m_dwSize);
+ std::unique_ptr<uint8_t, FxFreeDeleter> p(FX_Alloc(uint8_t, m_dwSize));
+ FXSYS_memcpy(p.get(), m_pData, m_dwSize);
return p;
}
diff --git a/core/fpdfapi/parser/cpdf_stream_acc.h b/core/fpdfapi/parser/cpdf_stream_acc.h
index 654055f96b..24ae5d2ed8 100644
--- a/core/fpdfapi/parser/cpdf_stream_acc.h
+++ b/core/fpdfapi/parser/cpdf_stream_acc.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_
#define CORE_FPDFAPI_PARSER_CPDF_STREAM_ACC_H_
+#include <memory>
+
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fxcrt/fx_string.h"
@@ -31,7 +33,7 @@ class CPDF_StreamAcc {
uint32_t GetSize() const;
const CFX_ByteString& GetImageDecoder() const { return m_ImageDecoder; }
const CPDF_Dictionary* GetImageParam() const { return m_pImageParam; }
- uint8_t* DetachData();
+ std::unique_ptr<uint8_t, FxFreeDeleter> DetachData();
protected:
uint8_t* m_pData;