summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-03 17:05:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-03 17:05:08 -0700
commit4de3d095c9d9e961f93750cf1ebd489fd515be12 (patch)
tree81db6141dde9336ec31be9ceadb0183433a394bf /core/fpdfapi
parent7f3a8c3c317b291b44521a6a0c4dd192ad2d5966 (diff)
downloadpdfium-4de3d095c9d9e961f93750cf1ebd489fd515be12.tar.xz
Remove CPDF_Object::Release() in favor of direct delete
Follow-on once we prove Release always deletes in previous CL. Review-Url: https://codereview.chromium.org/2384883003
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/edit/cpdf_creator.h2
-rw-r--r--core/fpdfapi/edit/fpdf_edit_create.cpp14
-rw-r--r--core/fpdfapi/font/fpdf_font.cpp7
-rw-r--r--core/fpdfapi/page/cpdf_contentmark.cpp3
-rw-r--r--core/fpdfapi/page/cpdf_contentmarkitem.cpp2
-rw-r--r--core/fpdfapi/page/cpdf_contentmarkitem.h6
-rw-r--r--core/fpdfapi/page/cpdf_image.cpp18
-rw-r--r--core/fpdfapi/page/cpdf_image.h6
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.cpp43
-rw-r--r--core/fpdfapi/page/cpdf_streamcontentparser.h2
-rw-r--r--core/fpdfapi/page/fpdf_page_parser_old.cpp16
-rw-r--r--core/fpdfapi/parser/cfdf_document.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_array.cpp13
-rw-r--r--core/fpdfapi/parser/cpdf_array.h8
-rw-r--r--core/fpdfapi/parser/cpdf_array_unittest.cpp26
-rw-r--r--core/fpdfapi/parser/cpdf_data_avail.cpp61
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.cpp8
-rw-r--r--core/fpdfapi/parser/cpdf_dictionary.h11
-rw-r--r--core/fpdfapi/parser/cpdf_document.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_document_unittest.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_indirect_object_holder.h2
-rw-r--r--core/fpdfapi/parser/cpdf_object.cpp5
-rw-r--r--core/fpdfapi/parser/cpdf_object.h8
-rw-r--r--core/fpdfapi/parser/cpdf_object_unittest.cpp76
-rw-r--r--core/fpdfapi/parser/cpdf_parser.cpp54
-rw-r--r--core/fpdfapi/parser/cpdf_stream.cpp2
-rw-r--r--core/fpdfapi/parser/cpdf_stream.h10
-rw-r--r--core/fpdfapi/parser/cpdf_string.h3
-rw-r--r--core/fpdfapi/parser/cpdf_syntax_parser.cpp17
30 files changed, 183 insertions, 251 deletions
diff --git a/core/fpdfapi/edit/cpdf_creator.h b/core/fpdfapi/edit/cpdf_creator.h
index f462115cf7..c04db6eb37 100644
--- a/core/fpdfapi/edit/cpdf_creator.h
+++ b/core/fpdfapi/edit/cpdf_creator.h
@@ -94,7 +94,7 @@ class CPDF_Creator {
FX_FILESIZE m_XrefStart;
CFX_FileSizeListArray m_ObjectOffset;
CFX_ArrayTemplate<uint32_t> m_NewObjNumArray;
- std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> m_pIDArray;
+ std::unique_ptr<CPDF_Array> m_pIDArray;
int32_t m_FileVersion;
};
diff --git a/core/fpdfapi/edit/fpdf_edit_create.cpp b/core/fpdfapi/edit/fpdf_edit_create.cpp
index ed638d4c40..a578a0a114 100644
--- a/core/fpdfapi/edit/fpdf_edit_create.cpp
+++ b/core/fpdfapi/edit/fpdf_edit_create.cpp
@@ -470,8 +470,8 @@ CPDF_FlateEncoder::CPDF_FlateEncoder(const uint8_t* pBuffer,
}
CPDF_FlateEncoder::~CPDF_FlateEncoder() {
- if (m_bCloned && m_pDict)
- m_pDict->Release();
+ if (m_bCloned)
+ delete m_pDict;
if (m_bNewData)
FX_Free(m_pData);
}
@@ -902,8 +902,8 @@ CPDF_Creator::CPDF_Creator(CPDF_Document* pDoc)
CPDF_Creator::~CPDF_Creator() {
ResetStandardSecurity();
- if (m_bEncryptCloned && m_pEncryptDict) {
- m_pEncryptDict->Release();
+ if (m_bEncryptCloned) {
+ delete m_pEncryptDict;
m_pEncryptDict = nullptr;
}
Clear();
@@ -1247,7 +1247,7 @@ int32_t CPDF_Creator::WriteOldIndirectObject(uint32_t objnum) {
return -1;
}
if (!bExistInMap) {
- m_pDocument->ReleaseIndirectObject(objnum);
+ m_pDocument->DeleteIndirectObject(objnum);
}
} else {
uint8_t* pBuffer;
@@ -1934,7 +1934,7 @@ void CPDF_Creator::InitID(bool bDefault) {
m_pIDArray->Add(pID1->Clone());
} else {
std::vector<uint8_t> buffer =
- PDF_GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum);
+ PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
CFX_ByteString bsBuffer(buffer.data(), buffer.size());
m_pIDArray->Add(new CPDF_String(bsBuffer, true));
}
@@ -1949,7 +1949,7 @@ void CPDF_Creator::InitID(bool bDefault) {
return;
}
std::vector<uint8_t> buffer =
- PDF_GenerateFileID((uint32_t)(uintptr_t)this, m_dwLastObjNum);
+ PDF_GenerateFileID((uint32_t)(uintptr_t) this, m_dwLastObjNum);
CFX_ByteString bsBuffer(buffer.data(), buffer.size());
m_pIDArray->Add(new CPDF_String(bsBuffer, true));
return;
diff --git a/core/fpdfapi/font/fpdf_font.cpp b/core/fpdfapi/font/fpdf_font.cpp
index c827ea5793..b681edf70b 100644
--- a/core/fpdfapi/font/fpdf_font.cpp
+++ b/core/fpdfapi/font/fpdf_font.cpp
@@ -47,11 +47,8 @@ CFX_StockFontArray::CFX_StockFontArray() {}
CFX_StockFontArray::~CFX_StockFontArray() {
for (size_t i = 0; i < FX_ArraySize(m_StockFonts); ++i) {
- if (!m_StockFonts[i])
- continue;
- CPDF_Dictionary* pFontDict = m_StockFonts[i]->GetFontDict();
- if (pFontDict)
- pFontDict->Release();
+ if (m_StockFonts[i])
+ delete m_StockFonts[i]->GetFontDict();
}
}
diff --git a/core/fpdfapi/page/cpdf_contentmark.cpp b/core/fpdfapi/page/cpdf_contentmark.cpp
index d60e144d6e..a867409335 100644
--- a/core/fpdfapi/page/cpdf_contentmark.cpp
+++ b/core/fpdfapi/page/cpdf_contentmark.cpp
@@ -110,8 +110,7 @@ void CPDF_ContentMark::MarkData::AddMark(const CFX_ByteString& name,
if (pDict) {
if (bDirect) {
item.SetDirectDict(
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>(
- ToDictionary(pDict->Clone())));
+ std::unique_ptr<CPDF_Dictionary>(ToDictionary(pDict->Clone())));
} else {
item.SetPropertiesDict(pDict);
}
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.cpp b/core/fpdfapi/page/cpdf_contentmarkitem.cpp
index 597f8a595c..dffeada707 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.cpp
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.cpp
@@ -39,7 +39,7 @@ bool CPDF_ContentMarkItem::HasMCID() const {
}
void CPDF_ContentMarkItem::SetDirectDict(
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict) {
+ std::unique_ptr<CPDF_Dictionary> pDict) {
m_ParamType = DirectDict;
m_pDirectDict = std::move(pDict);
}
diff --git a/core/fpdfapi/page/cpdf_contentmarkitem.h b/core/fpdfapi/page/cpdf_contentmarkitem.h
index f1f06c3a38..ed2737111b 100644
--- a/core/fpdfapi/page/cpdf_contentmarkitem.h
+++ b/core/fpdfapi/page/cpdf_contentmarkitem.h
@@ -31,16 +31,14 @@ class CPDF_ContentMarkItem {
bool HasMCID() const;
void SetName(const CFX_ByteString& name) { m_MarkName = name; }
- void SetDirectDict(
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict);
+ void SetDirectDict(std::unique_ptr<CPDF_Dictionary> pDict);
void SetPropertiesDict(CPDF_Dictionary* pDict);
private:
CFX_ByteString m_MarkName;
ParamType m_ParamType;
CPDF_Dictionary* m_pPropertiesDict; // not owned.
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>
- m_pDirectDict;
+ std::unique_ptr<CPDF_Dictionary> m_pDirectDict;
};
#endif // CORE_FPDFAPI_PAGE_CPDF_CONTENTMARKITEM_H_
diff --git a/core/fpdfapi/page/cpdf_image.cpp b/core/fpdfapi/page/cpdf_image.cpp
index 23c6e4f786..976d6d8c47 100644
--- a/core/fpdfapi/page/cpdf_image.cpp
+++ b/core/fpdfapi/page/cpdf_image.cpp
@@ -25,14 +25,16 @@
CPDF_Image::CPDF_Image(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
-CPDF_Image::CPDF_Image(CPDF_Document* pDoc, UniqueStream pStream)
+CPDF_Image::CPDF_Image(CPDF_Document* pDoc,
+ std::unique_ptr<CPDF_Stream> pStream)
: m_pDocument(pDoc),
m_pStream(pStream.get()),
m_pOwnedStream(std::move(pStream)) {
if (!m_pStream)
return;
- m_pOwnedDict = ToDictionary(UniqueObject(m_pStream->GetDict()->Clone()));
+ m_pOwnedDict =
+ ToDictionary(std::unique_ptr<CPDF_Object>(m_pStream->GetDict()->Clone()));
m_pDict = m_pOwnedDict.get();
FinishInitialization();
}
@@ -61,13 +63,15 @@ void CPDF_Image::FinishInitialization() {
CPDF_Image* CPDF_Image::Clone() {
CPDF_Image* pImage = new CPDF_Image(m_pDocument);
if (m_pOwnedStream) {
- pImage->m_pOwnedStream = ToStream(UniqueObject(m_pOwnedStream->Clone()));
+ pImage->m_pOwnedStream =
+ ToStream(std::unique_ptr<CPDF_Object>(m_pOwnedStream->Clone()));
pImage->m_pStream = pImage->m_pOwnedStream.get();
} else {
pImage->m_pStream = m_pStream;
}
if (m_pOwnedDict) {
- pImage->m_pOwnedDict = ToDictionary(UniqueObject(m_pOwnedDict->Clone()));
+ pImage->m_pOwnedDict =
+ ToDictionary(std::unique_ptr<CPDF_Object>(m_pOwnedDict->Clone()));
pImage->m_pDict = pImage->m_pOwnedDict.get();
} else {
pImage->m_pDict = m_pDict;
@@ -289,10 +293,8 @@ void CPDF_Image::SetImage(const CFX_DIBitmap* pBitmap, int32_t iCompress) {
pNewBitmap->Copy(pBitmap);
pNewBitmap->ConvertFormat(FXDIB_Rgb);
SetImage(pNewBitmap, iCompress);
- if (pDict) {
- pDict->Release();
- pDict = nullptr;
- }
+ delete pDict;
+ pDict = nullptr;
FX_Free(dest_buf);
dest_buf = nullptr;
dest_size = 0;
diff --git a/core/fpdfapi/page/cpdf_image.h b/core/fpdfapi/page/cpdf_image.h
index f619845597..02308db647 100644
--- a/core/fpdfapi/page/cpdf_image.h
+++ b/core/fpdfapi/page/cpdf_image.h
@@ -28,7 +28,7 @@ class IFX_SeekableWriteStream;
class CPDF_Image {
public:
explicit CPDF_Image(CPDF_Document* pDoc);
- CPDF_Image(CPDF_Document* pDoc, UniqueStream pStream);
+ CPDF_Image(CPDF_Document* pDoc, std::unique_ptr<CPDF_Stream> pStream);
CPDF_Image(CPDF_Document* pDoc, uint32_t dwStreamObjNum);
~CPDF_Image();
@@ -84,8 +84,8 @@ class CPDF_Image {
CPDF_Document* const m_pDocument;
CPDF_Stream* m_pStream = nullptr;
CPDF_Dictionary* m_pDict = nullptr;
- UniqueStream m_pOwnedStream;
- UniqueDictionary m_pOwnedDict;
+ std::unique_ptr<CPDF_Stream> m_pOwnedStream;
+ std::unique_ptr<CPDF_Dictionary> m_pOwnedDict;
CPDF_Dictionary* m_pOC = nullptr;
};
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.cpp b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
index ed6701382c..7618f8271f 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.cpp
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.cpp
@@ -180,12 +180,8 @@ CPDF_StreamContentParser::CPDF_StreamContentParser(
CPDF_StreamContentParser::~CPDF_StreamContentParser() {
ClearAllParams();
FX_Free(m_pPathPoints);
- if (m_pLastImageDict) {
- m_pLastImageDict->Release();
- }
- if (m_pLastCloneImageDict) {
- m_pLastCloneImageDict->Release();
- }
+ delete m_pLastImageDict;
+ delete m_pLastCloneImageDict;
}
int CPDF_StreamContentParser::GetNextParamPos() {
@@ -194,10 +190,9 @@ int CPDF_StreamContentParser::GetNextParamPos() {
if (m_ParamStartPos == kParamBufSize) {
m_ParamStartPos = 0;
}
- if (m_ParamBuf[m_ParamStartPos].m_Type == 0) {
- if (CPDF_Object* pObject = m_ParamBuf[m_ParamStartPos].m_pObject)
- pObject->Release();
- }
+ if (m_ParamBuf[m_ParamStartPos].m_Type == 0)
+ delete m_ParamBuf[m_ParamStartPos].m_pObject;
+
return m_ParamStartPos;
}
int index = m_ParamStartPos + m_ParamCount;
@@ -244,10 +239,9 @@ void CPDF_StreamContentParser::AddObjectParam(CPDF_Object* pObj) {
void CPDF_StreamContentParser::ClearAllParams() {
uint32_t index = m_ParamStartPos;
for (uint32_t i = 0; i < m_ParamCount; i++) {
- if (m_ParamBuf[index].m_Type == 0) {
- if (CPDF_Object* pObject = m_ParamBuf[index].m_pObject)
- pObject->Release();
- }
+ if (m_ParamBuf[index].m_Type == 0)
+ delete m_ParamBuf[index].m_pObject;
+
index++;
if (index == kParamBufSize) {
index = 0;
@@ -531,7 +525,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
m_pSyntax->GetWordSize());
if (bsKeyword != "ID") {
m_pSyntax->SetPos(savePos);
- pDict->Release();
+ delete pDict;
return;
}
}
@@ -540,8 +534,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
CFX_ByteString key((const FX_CHAR*)m_pSyntax->GetWordBuf() + 1,
m_pSyntax->GetWordSize() - 1);
- std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
- m_pSyntax->ReadNextObject(false, 0));
+ std::unique_ptr<CPDF_Object> pObj(m_pSyntax->ReadNextObject(false, 0));
if (!key.IsEmpty()) {
uint32_t dwObjNum = pObj ? pObj->GetObjNum() : 0;
if (dwObjNum)
@@ -566,7 +559,8 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
}
pDict->SetNameFor("Subtype", "Image");
- UniqueStream pStream(m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj));
+ std::unique_ptr<CPDF_Stream> pStream(
+ m_pSyntax->ReadInlineStream(m_pDocument, pDict, pCSObj));
bool bGaveDictAway = !!pStream;
while (1) {
CPDF_StreamParser::SyntaxType type = m_pSyntax->ParseNextElement();
@@ -583,7 +577,7 @@ void CPDF_StreamContentParser::Handle_BeginImage() {
}
CPDF_ImageObject* pImgObj = AddImage(std::move(pStream));
if (!pImgObj && !bGaveDictAway)
- pDict->Release();
+ delete pDict;
}
void CPDF_StreamContentParser::Handle_BeginMarkedContent() {
@@ -669,10 +663,10 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() {
type = pXObject->GetDict()->GetStringFor("Subtype");
if (type == "Image") {
- CPDF_ImageObject* pObj =
- pXObject->IsInline()
- ? AddImage(UniqueStream(ToStream(pXObject->Clone())))
- : AddImage(pXObject->GetObjNum());
+ CPDF_ImageObject* pObj = pXObject->IsInline()
+ ? AddImage(std::unique_ptr<CPDF_Stream>(
+ ToStream(pXObject->Clone())))
+ : AddImage(pXObject->GetObjNum());
m_LastImageName = name;
m_pLastImage = pObj->GetImage();
@@ -704,7 +698,8 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) {
m_pObjectHolder->GetPageObjectList()->push_back(std::move(pFormObj));
}
-CPDF_ImageObject* CPDF_StreamContentParser::AddImage(UniqueStream pStream) {
+CPDF_ImageObject* CPDF_StreamContentParser::AddImage(
+ std::unique_ptr<CPDF_Stream> pStream) {
if (!pStream)
return nullptr;
diff --git a/core/fpdfapi/page/cpdf_streamcontentparser.h b/core/fpdfapi/page/cpdf_streamcontentparser.h
index 58008da96a..1ed2aaa4de 100644
--- a/core/fpdfapi/page/cpdf_streamcontentparser.h
+++ b/core/fpdfapi/page/cpdf_streamcontentparser.h
@@ -97,7 +97,7 @@ class CPDF_StreamContentParser {
void AddPathPoint(FX_FLOAT x, FX_FLOAT y, int flag);
void AddPathRect(FX_FLOAT x, FX_FLOAT y, FX_FLOAT w, FX_FLOAT h);
void AddPathObject(int FillType, bool bStroke);
- CPDF_ImageObject* AddImage(UniqueStream pStream);
+ CPDF_ImageObject* AddImage(std::unique_ptr<CPDF_Stream> pStream);
CPDF_ImageObject* AddImage(uint32_t streamObjNum);
CPDF_ImageObject* AddImage(CPDF_Image* pImage);
diff --git a/core/fpdfapi/page/fpdf_page_parser_old.cpp b/core/fpdfapi/page/fpdf_page_parser_old.cpp
index 0d1db43825..51ffc11b03 100644
--- a/core/fpdfapi/page/fpdf_page_parser_old.cpp
+++ b/core/fpdfapi/page/fpdf_page_parser_old.cpp
@@ -138,9 +138,7 @@ CPDF_StreamParser::CPDF_StreamParser(
m_pPool(pPool) {}
CPDF_StreamParser::~CPDF_StreamParser() {
- if (m_pLastObj) {
- m_pLastObj->Release();
- }
+ delete m_pLastObj;
}
CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
@@ -252,10 +250,8 @@ CPDF_Stream* CPDF_StreamParser::ReadInlineStream(CPDF_Document* pDoc,
}
CPDF_StreamParser::SyntaxType CPDF_StreamParser::ParseNextElement() {
- if (m_pLastObj) {
- m_pLastObj->Release();
- m_pLastObj = nullptr;
- }
+ delete m_pLastObj;
+ m_pLastObj = nullptr;
m_WordSize = 0;
bool bIsNumber = true;
@@ -374,7 +370,7 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray,
break;
if (!m_WordSize || m_WordBuffer[0] != '/') {
- pDict->Release();
+ delete pDict;
return nullptr;
}
@@ -382,12 +378,12 @@ CPDF_Object* CPDF_StreamParser::ReadNextObject(bool bAllowNestedArray,
PDF_NameDecode(CFX_ByteStringC(m_WordBuffer + 1, m_WordSize - 1));
CPDF_Object* pObj = ReadNextObject(true, 0);
if (!pObj) {
- pDict->Release();
+ delete pDict;
return nullptr;
}
if (key.IsEmpty())
- pObj->Release();
+ delete pObj;
else
pDict->SetFor(key, pObj);
}
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index d39ec31d3c..dcd4b3c109 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -81,7 +81,7 @@ void CFDF_Document::ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile) {
if (CPDF_Dictionary* pMainDict =
ToDictionary(parser.GetObject(this, 0, 0, true))) {
m_pRootDict = pMainDict->GetDictFor("Root");
- pMainDict->Release();
+ delete pMainDict;
}
break;
}
diff --git a/core/fpdfapi/parser/cpdf_array.cpp b/core/fpdfapi/parser/cpdf_array.cpp
index e118fd66e6..4000bbc980 100644
--- a/core/fpdfapi/parser/cpdf_array.cpp
+++ b/core/fpdfapi/parser/cpdf_array.cpp
@@ -24,7 +24,7 @@ CPDF_Array::~CPDF_Array() {
m_ObjNum = kInvalidObjNum;
for (auto& it : m_Objects) {
if (it && it->GetObjNum() != kInvalidObjNum)
- it->Release();
+ delete it;
}
}
@@ -139,10 +139,9 @@ void CPDF_Array::RemoveAt(size_t i, size_t nCount) {
if (nCount <= 0 || nCount > m_Objects.size() - i)
return;
- for (size_t j = 0; j < nCount; ++j) {
- if (CPDF_Object* p = m_Objects[i + j])
- p->Release();
- }
+ for (size_t j = 0; j < nCount; ++j)
+ delete m_Objects[i + j];
+
m_Objects.erase(m_Objects.begin() + i, m_Objects.begin() + i + nCount);
}
@@ -166,9 +165,7 @@ void CPDF_Array::SetAt(size_t i, CPDF_Object* pObj) {
ASSERT(false);
return;
}
- if (CPDF_Object* pOld = m_Objects[i])
- pOld->Release();
-
+ delete m_Objects[i];
m_Objects[i] = pObj;
}
diff --git a/core/fpdfapi/parser/cpdf_array.h b/core/fpdfapi/parser/cpdf_array.h
index 8cfa0333bb..9deb478809 100644
--- a/core/fpdfapi/parser/cpdf_array.h
+++ b/core/fpdfapi/parser/cpdf_array.h
@@ -21,6 +21,7 @@ class CPDF_Array : public CPDF_Object {
using const_iterator = std::vector<CPDF_Object*>::const_iterator;
CPDF_Array();
+ ~CPDF_Array() override;
// CPDF_Object.
Type GetType() const override;
@@ -61,15 +62,12 @@ class CPDF_Array : public CPDF_Object {
const_iterator end() const { return m_Objects.end(); }
protected:
- ~CPDF_Array() override;
-
CPDF_Object* CloneNonCyclic(
bool bDirect,
std::set<const CPDF_Object*>* pVisited) const override;
std::vector<CPDF_Object*> m_Objects;
};
-using UniqueArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Object>>;
inline CPDF_Array* ToArray(CPDF_Object* obj) {
return obj ? obj->AsArray() : nullptr;
@@ -79,12 +77,12 @@ inline const CPDF_Array* ToArray(const CPDF_Object* obj) {
return obj ? obj->AsArray() : nullptr;
}
-inline UniqueArray ToArray(UniqueObject obj) {
+inline std::unique_ptr<CPDF_Array> ToArray(std::unique_ptr<CPDF_Object> obj) {
CPDF_Array* pArray = ToArray(obj.get());
if (!pArray)
return nullptr;
obj.release();
- return UniqueArray(pArray);
+ return std::unique_ptr<CPDF_Array>(pArray);
}
#endif // CORE_FPDFAPI_PARSER_CPDF_ARRAY_H_
diff --git a/core/fpdfapi/parser/cpdf_array_unittest.cpp b/core/fpdfapi/parser/cpdf_array_unittest.cpp
index bc9f578021..800afb0f9a 100644
--- a/core/fpdfapi/parser/cpdf_array_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_array_unittest.cpp
@@ -10,16 +10,10 @@
#include "testing/gtest/include/gtest/gtest.h"
-namespace {
-
-using ScopedArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>>;
-
-} // namespace
-
TEST(cpdf_array, RemoveAt) {
{
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->AddInteger(elems[i]);
arr->RemoveAt(3, 3);
@@ -36,7 +30,7 @@ TEST(cpdf_array, RemoveAt) {
{
// When the range is out of bound, RemoveAt has no effect.
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->AddInteger(elems[i]);
arr->RemoveAt(8, 5);
@@ -53,7 +47,7 @@ TEST(cpdf_array, RemoveAt) {
TEST(cpdf_array, InsertAt) {
{
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
EXPECT_EQ(FX_ArraySize(elems), arr->GetCount());
@@ -72,7 +66,7 @@ TEST(cpdf_array, InsertAt) {
// an element is inserted at that position while other unfilled
// positions have nullptr.
int elems[] = {1, 2};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
arr->InsertAt(10, new CPDF_Number(10));
@@ -89,10 +83,10 @@ TEST(cpdf_array, Clone) {
{
// Basic case.
int elems[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
- ScopedArray arr2(arr->Clone()->AsArray());
+ std::unique_ptr<CPDF_Array> arr2(arr->Clone()->AsArray());
EXPECT_EQ(arr->GetCount(), arr2->GetCount());
for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
// Clone() always create new objects.
@@ -106,7 +100,7 @@ TEST(cpdf_array, Clone) {
static const size_t kNumOfRowElems = 5;
int elems[kNumOfRows][kNumOfRowElems] = {
{1, 2, 3, 4, 5}, {10, 9, 8, 7, 6}, {11, 12, 13, 14, 15}};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
// Indirect references to indirect objects.
std::unique_ptr<CPDF_IndirectObjectHolder> obj_holder(
new CPDF_IndirectObjectHolder());
@@ -124,10 +118,10 @@ TEST(cpdf_array, Clone) {
ASSERT_EQ(kNumOfRows, arr->GetCount());
// Not dereferencing reference objects means just creating new references
// instead of new copies of direct objects.
- ScopedArray arr1(arr->Clone()->AsArray());
+ std::unique_ptr<CPDF_Array> arr1(arr->Clone()->AsArray());
EXPECT_EQ(arr->GetCount(), arr1->GetCount());
// Dereferencing reference objects creates new copies of direct objects.
- ScopedArray arr2(arr->CloneDirectObject()->AsArray());
+ std::unique_ptr<CPDF_Array> arr2(arr->CloneDirectObject()->AsArray());
EXPECT_EQ(arr->GetCount(), arr2->GetCount());
for (size_t i = 0; i < kNumOfRows; ++i) {
CPDF_Array* arr_elem = arr->GetObjectAt(i)->AsArray();
@@ -171,7 +165,7 @@ TEST(cpdf_array, Clone) {
TEST(cpdf_array, Iterator) {
int elems[] = {-23, -11, 3, 455, 2345877,
0, 7895330, -12564334, 10000, -100000};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(elems); ++i)
arr->InsertAt(i, new CPDF_Number(elems[i]));
size_t index = 0;
diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp
index a077ebb715..eadbf1e828 100644
--- a/core/fpdfapi/parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/parser/cpdf_data_avail.cpp
@@ -83,17 +83,12 @@ CPDF_DataAvail::CPDF_DataAvail(FileAvail* pFileAvail,
CPDF_DataAvail::~CPDF_DataAvail() {
m_pHintTables.reset();
- if (m_pLinearized)
- m_pLinearized->Release();
-
- if (m_pRoot)
- m_pRoot->Release();
-
- if (m_pTrailer)
- m_pTrailer->Release();
+ delete m_pLinearized;
+ delete m_pRoot;
+ delete m_pTrailer;
for (CPDF_Object* pObject : m_arrayAcroforms)
- pObject->Release();
+ delete pObject;
}
void CPDF_DataAvail::SetDocument(CPDF_Document* pDoc) {
@@ -230,7 +225,7 @@ bool CPDF_DataAvail::CheckAcroFormSubObject(DownloadHints* pHints) {
}
for (CPDF_Object* pObject : m_arrayAcroforms)
- pObject->Release();
+ delete pObject;
m_arrayAcroforms.clear();
return true;
@@ -400,9 +395,7 @@ bool CPDF_DataAvail::CheckInfo(DownloadHints* pHints) {
return false;
}
- if (pInfo)
- pInfo->Release();
-
+ delete pInfo;
m_docStatus =
(m_bHaveAcroForm ? PDF_DATAAVAIL_ACROFORM : PDF_DATAAVAIL_PAGETREE);
@@ -499,7 +492,7 @@ bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
}
if (!pObj->IsDictionary()) {
- pObj->Release();
+ delete pObj;
continue;
}
@@ -508,7 +501,7 @@ bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
m_PagesArray.push_back(pObj);
continue;
}
- pObj->Release();
+ delete pObj;
}
m_PageObjList.RemoveAll();
@@ -524,15 +517,15 @@ bool CPDF_DataAvail::CheckPage(DownloadHints* pHints) {
continue;
if (!GetPageKids(m_pCurrentParser, pPages)) {
- pPages->Release();
+ delete pPages;
while (++i < iPages)
- m_PagesArray[i]->Release();
+ delete m_PagesArray[i];
m_PagesArray.clear();
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
- pPages->Release();
+ delete pPages;
}
m_PagesArray.clear();
@@ -587,12 +580,12 @@ bool CPDF_DataAvail::CheckPages(DownloadHints* pHints) {
}
if (!GetPageKids(m_pCurrentParser, pPages)) {
- pPages->Release();
+ delete pPages;
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
- pPages->Release();
+ delete pPages;
m_docStatus = PDF_DATAAVAIL_PAGE;
return true;
}
@@ -763,7 +756,7 @@ bool CPDF_DataAvail::CheckHintTables(DownloadHints* pHints) {
std::unique_ptr<CPDF_HintTables> pHintTables(
new CPDF_HintTables(this, pDict));
- std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pHintStream(
+ std::unique_ptr<CPDF_Object> pHintStream(
ParseIndirectObjectAt(szHintStart, 0));
CPDF_Stream* pStream = ToStream(pHintStream.get());
if (pStream && pHintTables->LoadHintStream(pStream))
@@ -951,11 +944,11 @@ int32_t CPDF_DataAvail::CheckCrossRefStream(DownloadHints* pHints,
if (pName->GetString() == "XRef") {
m_Pos += m_parser.m_pSyntax->SavePos();
xref_offset = pObj->GetDict()->GetIntegerFor("Prev");
- pObj->Release();
+ delete pObj;
return 1;
}
}
- pObj->Release();
+ delete pObj;
return -1;
}
pHints->AddSegment(m_Pos, req_size);
@@ -1181,7 +1174,7 @@ bool CPDF_DataAvail::CheckTrailer(DownloadHints* pHints) {
ScopedFileStream file(FX_CreateMemoryStream(pBuf, (size_t)iSize, false));
m_syntaxParser.InitParser(file.get(), 0);
- std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pTrailer(
+ std::unique_ptr<CPDF_Object> pTrailer(
m_syntaxParser.GetObject(nullptr, 0, 0, true));
if (!pTrailer) {
m_Pos += m_syntaxParser.SavePos();
@@ -1266,7 +1259,7 @@ bool CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo,
CPDF_Array* pArray = pPages->AsArray();
if (!pArray) {
- pPages->Release();
+ delete pPages;
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
@@ -1281,7 +1274,7 @@ bool CPDF_DataAvail::CheckArrayPageNode(uint32_t dwPageNo,
pPageNode->m_childNode.Add(pNode);
pNode->m_dwPageNo = pKid->GetRefObjNum();
}
- pPages->Release();
+ delete pPages;
return true;
}
@@ -1304,12 +1297,12 @@ bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
if (pPage->IsArray()) {
pPageNode->m_dwPageNo = dwPageNo;
pPageNode->m_type = PDF_PAGENODE_ARRAY;
- pPage->Release();
+ delete pPage;
return true;
}
if (!pPage->IsDictionary()) {
- pPage->Release();
+ delete pPage;
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
@@ -1350,11 +1343,11 @@ bool CPDF_DataAvail::CheckUnkownPageNode(uint32_t dwPageNo,
} else if (type == "Page") {
pPageNode->m_type = PDF_PAGENODE_PAGE;
} else {
- pPage->Release();
+ delete pPage;
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
- pPage->Release();
+ delete pPage;
return true;
}
@@ -1442,23 +1435,23 @@ bool CPDF_DataAvail::CheckPageCount(DownloadHints* pHints) {
CPDF_Dictionary* pPagesDict = pPages->GetDict();
if (!pPagesDict) {
- pPages->Release();
+ delete pPages;
m_docStatus = PDF_DATAAVAIL_ERROR;
return false;
}
if (!pPagesDict->KeyExist("Kids")) {
- pPages->Release();
+ delete pPages;
return true;
}
int count = pPagesDict->GetIntegerFor("Count");
if (count > 0) {
- pPages->Release();
+ delete pPages;
return true;
}
- pPages->Release();
+ delete pPages;
return false;
}
diff --git a/core/fpdfapi/parser/cpdf_dictionary.cpp b/core/fpdfapi/parser/cpdf_dictionary.cpp
index 75cb1e859c..37efbbc34a 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.cpp
+++ b/core/fpdfapi/parser/cpdf_dictionary.cpp
@@ -31,7 +31,7 @@ CPDF_Dictionary::~CPDF_Dictionary() {
m_ObjNum = kInvalidObjNum;
for (const auto& it : m_Map) {
if (it.second && it.second->GetObjNum() != kInvalidObjNum)
- it.second->Release();
+ delete it.second;
}
}
@@ -184,7 +184,7 @@ void CPDF_Dictionary::SetFor(const CFX_ByteString& key, CPDF_Object* pObj) {
if (it->second == pObj)
return;
- it->second->Release();
+ delete it->second;
if (pObj)
it->second = pObj;
@@ -208,7 +208,7 @@ void CPDF_Dictionary::RemoveFor(const CFX_ByteString& key) {
if (it == m_Map.end())
return;
- it->second->Release();
+ delete it->second;
m_Map.erase(it);
}
@@ -223,7 +223,7 @@ void CPDF_Dictionary::ReplaceKey(const CFX_ByteString& oldkey,
return;
if (new_it != m_Map.end()) {
- new_it->second->Release();
+ delete new_it->second;
new_it->second = old_it->second;
} else {
m_Map.insert(std::make_pair(MaybeIntern(newkey), old_it->second));
diff --git a/core/fpdfapi/parser/cpdf_dictionary.h b/core/fpdfapi/parser/cpdf_dictionary.h
index fb8200f78c..4ef2f96ce7 100644
--- a/core/fpdfapi/parser/cpdf_dictionary.h
+++ b/core/fpdfapi/parser/cpdf_dictionary.h
@@ -26,6 +26,7 @@ class CPDF_Dictionary : public CPDF_Object {
CPDF_Dictionary();
explicit CPDF_Dictionary(const CFX_WeakPtr<CFX_ByteStringPool>& pPool);
+ ~CPDF_Dictionary() override;
// CPDF_Object.
Type GetType() const override;
@@ -88,8 +89,6 @@ class CPDF_Dictionary : public CPDF_Object {
CFX_WeakPtr<CFX_ByteStringPool> GetByteStringPool() const { return m_pPool; }
protected:
- ~CPDF_Dictionary() override;
-
CFX_ByteString MaybeIntern(const CFX_ByteString& str);
CPDF_Object* CloneNonCyclic(
bool bDirect,
@@ -99,9 +98,6 @@ class CPDF_Dictionary : public CPDF_Object {
std::map<CFX_ByteString, CPDF_Object*> m_Map;
};
-using UniqueDictionary =
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Object>>;
-
inline CPDF_Dictionary* ToDictionary(CPDF_Object* obj) {
return obj ? obj->AsDictionary() : nullptr;
}
@@ -110,12 +106,13 @@ inline const CPDF_Dictionary* ToDictionary(const CPDF_Object* obj) {
return obj ? obj->AsDictionary() : nullptr;
}
-inline UniqueDictionary ToDictionary(UniqueObject obj) {
+inline std::unique_ptr<CPDF_Dictionary> ToDictionary(
+ std::unique_ptr<CPDF_Object> obj) {
CPDF_Dictionary* pDict = ToDictionary(obj.get());
if (!pDict)
return nullptr;
obj.release();
- return UniqueDictionary(pDict);
+ return std::unique_ptr<CPDF_Dictionary>(pDict);
}
#endif // CORE_FPDFAPI_PARSER_CPDF_DICTIONARY_H_
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index ad84a15a97..64574047e5 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -634,7 +634,7 @@ CPDF_Dictionary* CPDF_Document::CreateNewPage(int iPage) {
pDict->SetNameFor("Type", "Page");
uint32_t dwObjNum = AddIndirectObject(pDict);
if (!InsertNewPage(iPage, pDict)) {
- ReleaseIndirectObject(dwObjNum);
+ DeleteIndirectObject(dwObjNum);
return nullptr;
}
return pDict;
diff --git a/core/fpdfapi/parser/cpdf_document_unittest.cpp b/core/fpdfapi/parser/cpdf_document_unittest.cpp
index 9336626f45..c09665b716 100644
--- a/core/fpdfapi/parser/cpdf_document_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_document_unittest.cpp
@@ -76,8 +76,7 @@ class CPDF_TestDocumentForPages : public CPDF_Document {
}
private:
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>
- m_pOwnedRootDict;
+ std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict;
};
} // namespace
@@ -121,7 +120,7 @@ TEST_F(cpdf_document_test, UseCachedPageObjNumIfHaveNotPagesDict) {
// can be not exists in this case.
// (case, when hint table is used to page check in CPDF_DataAvail).
CPDF_Document document(pdfium::MakeUnique<CPDF_Parser>());
- ScopedDictionary dict(new CPDF_Dictionary());
+ std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary());
const int page_count = 100;
dict->SetIntegerFor("N", page_count);
document.LoadLinearizedDoc(dict.get());
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
index 6e549de5a7..427fac66e4 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.cpp
@@ -70,7 +70,7 @@ bool CPDF_IndirectObjectHolder::ReplaceIndirectObjectIfHigherGeneration(
return true;
}
-void CPDF_IndirectObjectHolder::ReleaseIndirectObject(uint32_t objnum) {
+void CPDF_IndirectObjectHolder::DeleteIndirectObject(uint32_t objnum) {
CPDF_Object* pObj = GetIndirectObject(objnum);
if (!pObj || pObj->GetObjNum() == CPDF_Object::kInvalidObjNum)
return;
diff --git a/core/fpdfapi/parser/cpdf_indirect_object_holder.h b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
index da4e942b5d..83a31535c4 100644
--- a/core/fpdfapi/parser/cpdf_indirect_object_holder.h
+++ b/core/fpdfapi/parser/cpdf_indirect_object_holder.h
@@ -24,7 +24,7 @@ class CPDF_IndirectObjectHolder {
CPDF_Object* GetIndirectObject(uint32_t objnum) const;
CPDF_Object* GetOrParseIndirectObject(uint32_t objnum);
- void ReleaseIndirectObject(uint32_t objnum);
+ void DeleteIndirectObject(uint32_t objnum);
// Take ownership of |pObj|.
uint32_t AddIndirectObject(CPDF_Object* pObj);
diff --git a/core/fpdfapi/parser/cpdf_object.cpp b/core/fpdfapi/parser/cpdf_object.cpp
index cc410d10c8..e9c215ce19 100644
--- a/core/fpdfapi/parser/cpdf_object.cpp
+++ b/core/fpdfapi/parser/cpdf_object.cpp
@@ -37,11 +37,6 @@ CPDF_Object* CPDF_Object::CloneNonCyclic(
return Clone();
}
-void CPDF_Object::Release() {
- CHECK(!m_ObjNum);
- delete this;
-}
-
CFX_ByteString CPDF_Object::GetString() const {
return CFX_ByteString();
}
diff --git a/core/fpdfapi/parser/cpdf_object.h b/core/fpdfapi/parser/cpdf_object.h
index c888605d72..8f6491ec72 100644
--- a/core/fpdfapi/parser/cpdf_object.h
+++ b/core/fpdfapi/parser/cpdf_object.h
@@ -38,6 +38,8 @@ class CPDF_Object {
REFERENCE
};
+ virtual ~CPDF_Object();
+
virtual Type GetType() const = 0;
uint32_t GetObjNum() const { return m_ObjNum; }
uint32_t GetGenNum() const { return m_GenNum; }
@@ -50,8 +52,6 @@ class CPDF_Object {
virtual CPDF_Object* CloneDirectObject() const;
virtual CPDF_Object* GetDirect() const;
- void Release();
-
virtual CFX_ByteString GetString() const;
virtual CFX_WideString GetUnicodeText() const;
virtual FX_FLOAT GetNumber() const;
@@ -94,10 +94,8 @@ class CPDF_Object {
friend class CPDF_Parser;
friend class CPDF_Reference;
friend class CPDF_Stream;
- friend struct std::default_delete<CPDF_Object>;
CPDF_Object() : m_ObjNum(0), m_GenNum(0) {}
- virtual ~CPDF_Object();
CPDF_Object* CloneObjectNonCyclic(bool bDirect) const;
@@ -118,6 +116,4 @@ class CPDF_Object {
CPDF_Object(const CPDF_Object& src) {}
};
-using UniqueObject = std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>>;
-
#endif // CORE_FPDFAPI_PARSER_CPDF_OBJECT_H_
diff --git a/core/fpdfapi/parser/cpdf_object_unittest.cpp b/core/fpdfapi/parser/cpdf_object_unittest.cpp
index 8215226ef3..64dc8c63ec 100644
--- a/core/fpdfapi/parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/parser/cpdf_object_unittest.cpp
@@ -22,11 +22,6 @@
namespace {
-using ScopedArray = std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>>;
-using ScopedDict =
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>>;
-using ScopedStream = std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Stream>>;
-
void TestArrayAccessors(const CPDF_Array* arr,
size_t index,
const char* str_val,
@@ -173,14 +168,12 @@ class PDFObjectsTest : public testing::Test {
}
protected:
- using ScopedObj = std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>>;
-
// m_ObjHolder needs to be declared first and destructed last since it also
// refers to some objects in m_DirectObjs.
std::unique_ptr<CPDF_IndirectObjectHolder> m_ObjHolder;
- std::vector<ScopedObj> m_DirectObjs;
+ std::vector<std::unique_ptr<CPDF_Object>> m_DirectObjs;
std::vector<int> m_DirectObjTypes;
- std::vector<ScopedObj> m_RefObjs;
+ std::vector<std::unique_ptr<CPDF_Object>> m_RefObjs;
CPDF_Dictionary* m_DictObj;
CPDF_Dictionary* m_StreamDictObj;
CPDF_Array* m_ArrayObj;
@@ -275,13 +268,13 @@ TEST_F(PDFObjectsTest, GetArray) {
TEST_F(PDFObjectsTest, Clone) {
// Check for direct objects.
for (size_t i = 0; i < m_DirectObjs.size(); ++i) {
- ScopedObj obj(m_DirectObjs[i]->Clone());
+ std::unique_ptr<CPDF_Object> obj(m_DirectObjs[i]->Clone());
EXPECT_TRUE(Equal(m_DirectObjs[i].get(), obj.get()));
}
// Check indirect references.
for (const auto& it : m_RefObjs) {
- ScopedObj obj(it->Clone());
+ std::unique_ptr<CPDF_Object> obj(it->Clone());
EXPECT_TRUE(Equal(it.get(), obj.get()));
}
}
@@ -393,7 +386,7 @@ TEST(PDFArrayTest, GetMatrix) {
{2.3f, 4.05f, 3, -2, -3, 0.0f},
{0.05f, 0.1f, 0.56f, 0.67f, 1.34f, 99.9f}};
for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
CFX_Matrix matrix(elems[i][0], elems[i][1], elems[i][2], elems[i][3],
elems[i][4], elems[i][5]);
for (size_t j = 0; j < 6; ++j)
@@ -414,7 +407,7 @@ TEST(PDFArrayTest, GetRect) {
{2.3f, 4.05f, -3, 0.0f},
{0.05f, 0.1f, 1.34f, 99.9f}};
for (size_t i = 0; i < FX_ArraySize(elems); ++i) {
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
CFX_FloatRect rect(elems[i]);
for (size_t j = 0; j < 4; ++j)
arr->AddNumber(elems[i][j]);
@@ -430,7 +423,7 @@ TEST(PDFArrayTest, GetTypeAt) {
{
// Boolean array.
const bool vals[] = {true, false, false, true, true};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i)
arr->InsertAt(i, new CPDF_Boolean(vals[i]));
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
@@ -447,7 +440,7 @@ TEST(PDFArrayTest, GetTypeAt) {
{
// Integer array.
const int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i)
arr->InsertAt(i, new CPDF_Number(vals[i]));
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
@@ -468,7 +461,7 @@ TEST(PDFArrayTest, GetTypeAt) {
897.34f, -2.5f, -1.0f, -345.0f, -0.0f};
const char* const expected_str[] = {
"0", "0", "10", "10", "0.0345", "897.34", "-2.5", "-1", "-345", "0"};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
arr->InsertAt(i, new CPDF_Number(vals[i]));
}
@@ -487,8 +480,8 @@ TEST(PDFArrayTest, GetTypeAt) {
// String and name array
const char* const vals[] = {"this", "adsde$%^", "\r\t", "\"012",
".", "EYREW", "It is a joke :)"};
- ScopedArray string_array(new CPDF_Array);
- ScopedArray name_array(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> string_array(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> name_array(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
string_array->InsertAt(i, new CPDF_String(vals[i], false));
name_array->InsertAt(i, new CPDF_Name(vals[i]));
@@ -514,7 +507,7 @@ TEST(PDFArrayTest, GetTypeAt) {
}
{
// Null element array.
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < 3; ++i)
arr->InsertAt(i, new CPDF_Null);
for (size_t i = 0; i < 3; ++i) {
@@ -531,7 +524,7 @@ TEST(PDFArrayTest, GetTypeAt) {
{
// Array of array.
CPDF_Array* vals[3];
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < 3; ++i) {
vals[i] = new CPDF_Array;
for (size_t j = 0; j < 3; ++j) {
@@ -554,7 +547,7 @@ TEST(PDFArrayTest, GetTypeAt) {
{
// Dictionary array.
CPDF_Dictionary* vals[3];
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < 3; ++i) {
vals[i] = new CPDF_Dictionary();
for (size_t j = 0; j < 3; ++j) {
@@ -581,7 +574,7 @@ TEST(PDFArrayTest, GetTypeAt) {
// Stream array.
CPDF_Dictionary* vals[3];
CPDF_Stream* stream_vals[3];
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < 3; ++i) {
vals[i] = new CPDF_Dictionary();
for (size_t j = 0; j < 3; ++j) {
@@ -611,7 +604,7 @@ TEST(PDFArrayTest, GetTypeAt) {
}
{
// Mixed array.
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
// Array arr will take ownership of all the objects inserted.
arr->InsertAt(0, new CPDF_Boolean(true));
arr->InsertAt(1, new CPDF_Boolean(false));
@@ -676,7 +669,7 @@ TEST(PDFArrayTest, GetTypeAt) {
TEST(PDFArrayTest, AddNumber) {
float vals[] = {1.0f, -1.0f, 0, 0.456734f,
12345.54321f, 0.5f, 1000, 0.000045f};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i)
arr->AddNumber(vals[i]);
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
@@ -687,7 +680,7 @@ TEST(PDFArrayTest, AddNumber) {
TEST(PDFArrayTest, AddInteger) {
int vals[] = {0, 1, 934435456, 876, 10000, -1, -24354656, -100};
- ScopedArray arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i)
arr->AddInteger(vals[i]);
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
@@ -699,8 +692,8 @@ TEST(PDFArrayTest, AddInteger) {
TEST(PDFArrayTest, AddStringAndName) {
const char* vals[] = {"", "a", "ehjhRIOYTTFdfcdnv", "122323",
"$#%^&**", " ", "This is a test.\r\n"};
- ScopedArray string_array(new CPDF_Array);
- ScopedArray name_array(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> string_array(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> name_array(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
string_array->AddString(vals[i]);
name_array->AddName(vals[i]);
@@ -725,8 +718,8 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) {
CPDF_Object* indirect_objs[] = {boolean_obj, int_obj, float_obj,
str_obj, name_obj, null_obj};
unsigned int obj_nums[] = {2, 4, 7, 2345, 799887, 1};
- ScopedArray arr(new CPDF_Array);
- ScopedArray arr1(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr1(new CPDF_Array);
// Create two arrays of references by different AddReference() APIs.
for (size_t i = 0; i < FX_ArraySize(indirect_objs); ++i) {
// All the indirect objects inserted will be owned by holder.
@@ -752,7 +745,7 @@ TEST(PDFArrayTest, AddReferenceAndGetObjectAt) {
TEST(PDFArrayTest, CloneDirectObject) {
CPDF_IndirectObjectHolder objects_holder;
- ScopedArray array(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> array(new CPDF_Array);
array->AddReference(&objects_holder, 1234);
ASSERT_EQ(1U, array->GetCount());
CPDF_Object* obj = array->GetObjectAt(0);
@@ -763,7 +756,7 @@ TEST(PDFArrayTest, CloneDirectObject) {
ASSERT_TRUE(cloned_array_object);
ASSERT_TRUE(cloned_array_object->IsArray());
- ScopedArray cloned_array(cloned_array_object->AsArray());
+ std::unique_ptr<CPDF_Array> cloned_array(cloned_array_object->AsArray());
ASSERT_EQ(1U, cloned_array->GetCount());
CPDF_Object* cloned_obj = cloned_array->GetObjectAt(0);
EXPECT_FALSE(cloned_obj);
@@ -771,7 +764,7 @@ TEST(PDFArrayTest, CloneDirectObject) {
TEST(PDFArrayTest, ConvertIndirect) {
CPDF_IndirectObjectHolder objects_holder;
- ScopedArray array(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> array(new CPDF_Array);
CPDF_Object* pObj = new CPDF_Number(42);
array->Add(pObj);
array->ConvertToIndirectObjectAt(0, &objects_holder);
@@ -786,7 +779,7 @@ TEST(PDFArrayTest, ConvertIndirect) {
TEST(PDFDictionaryTest, CloneDirectObject) {
CPDF_IndirectObjectHolder objects_holder;
- ScopedDict dict(new CPDF_Dictionary());
+ std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary());
dict->SetReferenceFor("foo", &objects_holder, 1234);
ASSERT_EQ(1U, dict->GetCount());
CPDF_Object* obj = dict->GetObjectFor("foo");
@@ -797,7 +790,8 @@ TEST(PDFDictionaryTest, CloneDirectObject) {
ASSERT_TRUE(cloned_dict_object);
ASSERT_TRUE(cloned_dict_object->IsDictionary());
- ScopedDict cloned_dict(cloned_dict_object->AsDictionary());
+ std::unique_ptr<CPDF_Dictionary> cloned_dict(
+ cloned_dict_object->AsDictionary());
ASSERT_EQ(1U, cloned_dict->GetCount());
CPDF_Object* cloned_obj = cloned_dict->GetObjectFor("foo");
EXPECT_FALSE(cloned_obj);
@@ -807,12 +801,12 @@ TEST(PDFObjectTest, CloneCheckLoop) {
{
// Create a dictionary/array pair with a reference loop.
CPDF_Dictionary* dict_obj = new CPDF_Dictionary();
- ScopedArray arr_obj(new CPDF_Array);
+ std::unique_ptr<CPDF_Array> arr_obj(new CPDF_Array);
dict_obj->SetFor("arr", arr_obj.get());
arr_obj->InsertAt(0, dict_obj);
// Clone this object to see whether stack overflow will be triggered.
- ScopedArray cloned_array(arr_obj->Clone()->AsArray());
+ std::unique_ptr<CPDF_Array> cloned_array(arr_obj->Clone()->AsArray());
// Cloned object should be the same as the original.
ASSERT_TRUE(cloned_array);
EXPECT_EQ(1u, cloned_array->GetCount());
@@ -825,11 +819,12 @@ TEST(PDFObjectTest, CloneCheckLoop) {
{
// Create a dictionary/stream pair with a reference loop.
CPDF_Dictionary* dict_obj = new CPDF_Dictionary();
- ScopedStream stream_obj(new CPDF_Stream(nullptr, 0, dict_obj));
+ std::unique_ptr<CPDF_Stream> stream_obj(
+ new CPDF_Stream(nullptr, 0, dict_obj));
dict_obj->SetFor("stream", stream_obj.get());
// Clone this object to see whether stack overflow will be triggered.
- ScopedStream cloned_stream(stream_obj->Clone()->AsStream());
+ std::unique_ptr<CPDF_Stream> cloned_stream(stream_obj->Clone()->AsStream());
// Cloned object should be the same as the original.
ASSERT_TRUE(cloned_stream);
CPDF_Object* cloned_dict = cloned_stream->GetDict();
@@ -855,7 +850,8 @@ TEST(PDFObjectTest, CloneCheckLoop) {
EXPECT_EQ(dict_obj, elem0->AsReference()->GetDirect());
// Clone this object to see whether stack overflow will be triggered.
- ScopedDict cloned_dict(ToDictionary(dict_obj->CloneDirectObject()));
+ std::unique_ptr<CPDF_Dictionary> cloned_dict(
+ ToDictionary(dict_obj->CloneDirectObject()));
// Cloned object should be the same as the original.
ASSERT_TRUE(cloned_dict);
CPDF_Object* cloned_arr = cloned_dict->GetObjectFor("arr");
@@ -869,7 +865,7 @@ TEST(PDFObjectTest, CloneCheckLoop) {
TEST(PDFDictionaryTest, ConvertIndirect) {
CPDF_IndirectObjectHolder objects_holder;
- ScopedDict dict(new CPDF_Dictionary);
+ std::unique_ptr<CPDF_Dictionary> dict(new CPDF_Dictionary);
CPDF_Object* pObj = new CPDF_Number(42);
dict->SetFor("clams", pObj);
dict->ConvertToIndirectObjectFor("clams", &objects_holder);
diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
index cff0f77b32..da95cc5f24 100644
--- a/core/fpdfapi/parser/cpdf_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_parser.cpp
@@ -61,9 +61,7 @@ CPDF_Parser::CPDF_Parser()
}
CPDF_Parser::~CPDF_Parser() {
- if (m_pTrailer)
- m_pTrailer->Release();
-
+ delete m_pTrailer;
ReleaseEncryptHandler();
SetEncryptDictionary(nullptr);
@@ -72,13 +70,10 @@ CPDF_Parser::~CPDF_Parser() {
m_pSyntax->m_pFileAccess = nullptr;
}
- for (CPDF_Dictionary* trailer : m_Trailers) {
- if (trailer)
- trailer->Release();
- }
+ for (CPDF_Dictionary* trailer : m_Trailers)
+ delete trailer;
- if (m_pLinearized)
- m_pLinearized->Release();
+ delete m_pLinearized;
}
uint32_t CPDF_Parser::GetLastObjNum() const {
@@ -357,8 +352,7 @@ bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
CrossRefList.insert(CrossRefList.begin(), xrefpos);
LoadCrossRefV4(xrefpos, 0, true);
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
- LoadTrailerV4());
+ std::unique_ptr<CPDF_Dictionary> pDict(LoadTrailerV4());
if (!pDict)
return false;
@@ -412,8 +406,7 @@ bool CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
CrossRefList.insert(CrossRefList.begin(), xrefpos);
LoadCrossRefV4(xrefpos, 0, true);
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
- LoadTrailerV4());
+ std::unique_ptr<CPDF_Dictionary> pDict(LoadTrailerV4());
if (!pDict)
return false;
@@ -590,18 +583,14 @@ bool CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) {
bool CPDF_Parser::RebuildCrossRef() {
m_ObjectInfo.clear();
m_SortedOffset.clear();
- if (m_pTrailer) {
- m_pTrailer->Release();
- m_pTrailer = nullptr;
- }
+ delete m_pTrailer;
+ m_pTrailer = nullptr;
ParserState state = ParserState::kDefault;
-
int32_t inside_index = 0;
uint32_t objnum = 0;
uint32_t gennum = 0;
int32_t depth = 0;
-
const uint32_t kBufferSize = 4096;
std::vector<uint8_t> buffer(kBufferSize);
@@ -755,8 +744,7 @@ bool CPDF_Parser::RebuildCrossRef() {
CPDF_Object* pRoot = pDict->GetObjectFor("Root");
if (pRoot && pRoot->GetDict() &&
pRoot->GetDict()->GetObjectFor("Pages")) {
- if (m_pTrailer)
- m_pTrailer->Release();
+ delete m_pTrailer;
m_pTrailer = ToDictionary(pDict->Clone());
}
}
@@ -794,8 +782,7 @@ bool CPDF_Parser::RebuildCrossRef() {
m_ObjectInfo[objnum].gennum = gennum;
}
- if (pObject)
- pObject->Release();
+ delete pObject;
}
--i;
state = ParserState::kDefault;
@@ -812,7 +799,7 @@ bool CPDF_Parser::RebuildCrossRef() {
CPDF_Object* pObj = m_pSyntax->GetObject(m_pDocument, 0, 0, true);
if (pObj) {
if (!pObj->IsDictionary() && !pObj->AsStream()) {
- pObj->Release();
+ delete pObj;
} else {
CPDF_Stream* pStream = pObj->AsStream();
if (CPDF_Dictionary* pTrailer =
@@ -838,11 +825,11 @@ bool CPDF_Parser::RebuildCrossRef() {
}
}
}
- pObj->Release();
+ delete pObj;
} else {
if (pObj->IsStream()) {
m_pTrailer = ToDictionary(pTrailer->Clone());
- pObj->Release();
+ delete pObj;
} else {
m_pTrailer = pTrailer;
}
@@ -859,7 +846,7 @@ bool CPDF_Parser::RebuildCrossRef() {
m_pSyntax->RestorePos(dwSavePos);
}
} else {
- pObj->Release();
+ delete pObj;
}
}
}
@@ -1418,7 +1405,7 @@ CPDF_Dictionary* CPDF_Parser::LoadTrailerV4() {
if (m_pSyntax->GetKeyword() != "trailer")
return nullptr;
- std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> pObj(
+ std::unique_ptr<CPDF_Object> pObj(
m_pSyntax->GetObject(m_pDocument, 0, 0, true));
if (!ToDictionary(pObj.get()))
return nullptr;
@@ -1470,7 +1457,7 @@ bool CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
CPDF_Object* pLen = pDict->GetObjectFor("L");
if (!pLen) {
- m_pLinearized->Release();
+ delete m_pLinearized;
m_pLinearized = nullptr;
return false;
}
@@ -1486,7 +1473,7 @@ bool CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
return true;
}
- m_pLinearized->Release();
+ delete m_pLinearized;
m_pLinearized = nullptr;
return false;
}
@@ -1595,12 +1582,11 @@ bool CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) {
CPDF_Parser::Error CPDF_Parser::LoadLinearizedMainXRefTable() {
uint32_t dwSaveMetadataObjnum = m_pSyntax->m_MetadataObjnum;
m_pSyntax->m_MetadataObjnum = 0;
- if (m_pTrailer) {
- m_pTrailer->Release();
- m_pTrailer = nullptr;
- }
+ delete m_pTrailer;
+ m_pTrailer = nullptr;
m_pSyntax->RestorePos(m_LastXRefOffset - m_pSyntax->m_HeaderOffset);
+
uint8_t ch = 0;
uint32_t dwCount = 0;
m_pSyntax->GetNextChar(ch);
diff --git a/core/fpdfapi/parser/cpdf_stream.cpp b/core/fpdfapi/parser/cpdf_stream.cpp
index c6e99c84b5..11ef1d2dc1 100644
--- a/core/fpdfapi/parser/cpdf_stream.cpp
+++ b/core/fpdfapi/parser/cpdf_stream.cpp
@@ -15,7 +15,7 @@
CPDF_Stream::CPDF_Stream() {}
CPDF_Stream::CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict)
- : m_pDict(pDict), m_dwSize(size), m_pDataBuf(pData) {}
+ : m_dwSize(size), m_pDict(pDict), m_pDataBuf(pData) {}
CPDF_Stream::~CPDF_Stream() {
m_ObjNum = kInvalidObjNum;
diff --git a/core/fpdfapi/parser/cpdf_stream.h b/core/fpdfapi/parser/cpdf_stream.h
index 73484d8335..f0ba31924e 100644
--- a/core/fpdfapi/parser/cpdf_stream.h
+++ b/core/fpdfapi/parser/cpdf_stream.h
@@ -20,6 +20,7 @@ class CPDF_Stream : public CPDF_Object {
// Takes ownership of |pData| and |pDict|.
CPDF_Stream(uint8_t* pData, uint32_t size, CPDF_Dictionary* pDict);
+ ~CPDF_Stream() override;
// CPDF_Object.
Type GetType() const override;
@@ -47,20 +48,17 @@ class CPDF_Stream : public CPDF_Object {
bool IsMemoryBased() const { return m_bMemoryBased; }
protected:
- ~CPDF_Stream() override;
CPDF_Object* CloneNonCyclic(
bool bDirect,
std::set<const CPDF_Object*>* pVisited) const override;
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> m_pDict;
bool m_bMemoryBased = true;
uint32_t m_dwSize = 0;
+ std::unique_ptr<CPDF_Dictionary> m_pDict;
std::unique_ptr<uint8_t, FxFreeDeleter> m_pDataBuf;
IFX_SeekableReadStream* m_pFile = nullptr;
};
-using UniqueStream = std::unique_ptr<CPDF_Stream, ReleaseDeleter<CPDF_Object>>;
-
inline CPDF_Stream* ToStream(CPDF_Object* obj) {
return obj ? obj->AsStream() : nullptr;
}
@@ -69,12 +67,12 @@ inline const CPDF_Stream* ToStream(const CPDF_Object* obj) {
return obj ? obj->AsStream() : nullptr;
}
-inline UniqueStream ToStream(UniqueObject obj) {
+inline std::unique_ptr<CPDF_Stream> ToStream(std::unique_ptr<CPDF_Object> obj) {
CPDF_Stream* pStream = ToStream(obj.get());
if (!pStream)
return nullptr;
obj.release();
- return UniqueStream(pStream);
+ return std::unique_ptr<CPDF_Stream>(pStream);
}
#endif // CORE_FPDFAPI_PARSER_CPDF_STREAM_H_
diff --git a/core/fpdfapi/parser/cpdf_string.h b/core/fpdfapi/parser/cpdf_string.h
index efc6d076c7..49834c03f2 100644
--- a/core/fpdfapi/parser/cpdf_string.h
+++ b/core/fpdfapi/parser/cpdf_string.h
@@ -16,6 +16,7 @@ class CPDF_String : public CPDF_Object {
CPDF_String();
CPDF_String(const CFX_ByteString& str, bool bHex);
explicit CPDF_String(const CFX_WideString& str);
+ ~CPDF_String() override;
// CPDF_Object.
Type GetType() const override;
@@ -30,8 +31,6 @@ class CPDF_String : public CPDF_Object {
bool IsHex() const { return m_bHex; }
protected:
- ~CPDF_String() override;
-
CFX_ByteString m_String;
bool m_bHex;
};
diff --git a/core/fpdfapi/parser/cpdf_syntax_parser.cpp b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
index 178af3bb9b..da3c8b0c79 100644
--- a/core/fpdfapi/parser/cpdf_syntax_parser.cpp
+++ b/core/fpdfapi/parser/cpdf_syntax_parser.cpp
@@ -425,8 +425,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObject(CPDF_IndirectObjectHolder* pObjList,
int32_t nKeys = 0;
FX_FILESIZE dwSignValuePos = 0;
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
- new CPDF_Dictionary(m_pPool));
+ std::unique_ptr<CPDF_Dictionary> pDict(new CPDF_Dictionary(m_pPool));
while (1) {
CFX_ByteString key = GetNextWord(nullptr);
if (key.IsEmpty())
@@ -530,8 +529,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectForStrict(
}
if (word == "[") {
- std::unique_ptr<CPDF_Array, ReleaseDeleter<CPDF_Array>> pArray(
- new CPDF_Array);
+ std::unique_ptr<CPDF_Array> pArray(new CPDF_Array);
while (CPDF_Object* pObj = GetObject(pObjList, objnum, gennum, true))
pArray->Add(pObj);
@@ -544,8 +542,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectForStrict(
}
if (word == "<<") {
- std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
- new CPDF_Dictionary(m_pPool));
+ std::unique_ptr<CPDF_Dictionary> pDict(new CPDF_Dictionary(m_pPool));
while (1) {
FX_FILESIZE SavedPos = m_Pos;
CFX_ByteString key = GetNextWord(nullptr);
@@ -564,7 +561,7 @@ CPDF_Object* CPDF_SyntaxParser::GetObjectForStrict(
continue;
key = PDF_NameDecode(key);
- std::unique_ptr<CPDF_Object, ReleaseDeleter<CPDF_Object>> obj(
+ std::unique_ptr<CPDF_Object> obj(
GetObject(pObjList, objnum, gennum, true));
if (!obj) {
uint8_t ch;
@@ -692,7 +689,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
// Can't find "endstream" or "endobj".
if (endStreamOffset < 0 && endObjOffset < 0) {
- pDict->Release();
+ delete pDict;
return nullptr;
}
@@ -718,7 +715,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
}
if (len < 0) {
- pDict->Release();
+ delete pDict;
return nullptr;
}
pDict->SetIntegerFor("Length", len);
@@ -727,7 +724,7 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict,
}
if (len < 0) {
- pDict->Release();
+ delete pDict;
return nullptr;
}