Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2500)

Unified Diff: core/fpdfapi/fpdf_parser/cfdf_document.cpp

Issue 2019443002: Make CPDF_IndirectObjectHolder::InsertIndirectObject return a bool. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix bad refactoring Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/fpdf_parser/cfdf_document.cpp
diff --git a/core/fpdfapi/fpdf_parser/cfdf_document.cpp b/core/fpdfapi/fpdf_parser/cfdf_document.cpp
index 3039c329386283e8292867097b05d7720f4ad719..d4f49f659bdaedbf912909aae07516c7e45c2a3f 100644
--- a/core/fpdfapi/fpdf_parser/cfdf_document.cpp
+++ b/core/fpdfapi/fpdf_parser/cfdf_document.cpp
@@ -28,22 +28,21 @@ CFDF_Document* CFDF_Document::CreateNewDoc() {
pDoc->m_pRootDict->SetAt("FDF", pFDFDict);
return pDoc;
}
+
CFDF_Document* CFDF_Document::ParseFile(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
- if (!pFile) {
- return NULL;
- }
- CFDF_Document* pDoc = new CFDF_Document;
+ if (!pFile)
+ return nullptr;
+
+ std::unique_ptr<CFDF_Document> pDoc(new CFDF_Document);
pDoc->ParseStream(pFile, bOwnFile);
- if (!pDoc->m_pRootDict) {
- delete pDoc;
- return NULL;
- }
- return pDoc;
+ return pDoc->m_pRootDict ? pDoc.release() : nullptr;
}
+
CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, uint32_t size) {
return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size),
TRUE);
}
+
void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
m_pFile = pFile;
m_bOwnFile = bOwnFile;
@@ -55,26 +54,25 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
if (bNumber) {
uint32_t objnum = FXSYS_atoui(word.c_str());
word = parser.GetNextWord(&bNumber);
- if (!bNumber) {
+ if (!bNumber)
break;
- }
+
word = parser.GetNextWord(nullptr);
- if (word != "obj") {
+ if (word != "obj")
break;
- }
+
CPDF_Object* pObj = parser.GetObject(this, objnum, 0, true);
- if (!pObj) {
+ if (!pObj)
break;
- }
+
InsertIndirectObject(objnum, pObj);
word = parser.GetNextWord(nullptr);
- if (word != "endobj") {
+ if (word != "endobj")
break;
- }
} else {
- if (word != "trailer") {
+ if (word != "trailer")
break;
- }
+
if (CPDF_Dictionary* pMainDict =
ToDictionary(parser.GetObject(this, 0, 0, true))) {
m_pRootDict = pMainDict->GetDictBy("Root");
@@ -84,6 +82,7 @@ void CFDF_Document::ParseStream(IFX_FileRead* pFile, FX_BOOL bOwnFile) {
}
}
}
+
FX_BOOL CFDF_Document::WriteBuf(CFX_ByteTextBuf& buf) const {
if (!m_pRootDict) {
return FALSE;
« no previous file with comments | « no previous file | core/fpdfapi/fpdf_parser/cpdf_indirect_object_holder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698