| Index: core/fpdfapi/parser/cpdf_parser.cpp
|
| diff --git a/core/fpdfapi/parser/cpdf_parser.cpp b/core/fpdfapi/parser/cpdf_parser.cpp
|
| index c2748882cfde06fba94c4d0a550bbe0013e36e55..cff0f77b3247107d4a33d724480115955f432e67 100644
|
| --- a/core/fpdfapi/parser/cpdf_parser.cpp
|
| +++ b/core/fpdfapi/parser/cpdf_parser.cpp
|
| @@ -144,7 +144,7 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess,
|
| ASSERT(!m_bHasParsed);
|
| m_bHasParsed = true;
|
|
|
| - m_bXRefStream = FALSE;
|
| + m_bXRefStream = false;
|
| m_LastXRefOffset = 0;
|
| m_bOwnFileRead = true;
|
|
|
| @@ -173,8 +173,8 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess,
|
| m_pSyntax->RestorePos(m_pSyntax->m_FileLen - m_pSyntax->m_HeaderOffset - 9);
|
| m_pDocument = pDocument;
|
|
|
| - FX_BOOL bXRefRebuilt = FALSE;
|
| - if (m_pSyntax->SearchWord("startxref", TRUE, FALSE, 4096)) {
|
| + bool bXRefRebuilt = false;
|
| + if (m_pSyntax->SearchWord("startxref", true, false, 4096)) {
|
| m_SortedOffset.insert(m_pSyntax->SavePos());
|
| m_pSyntax->GetKeyword();
|
|
|
| @@ -189,14 +189,14 @@ CPDF_Parser::Error CPDF_Parser::StartParse(IFX_SeekableReadStream* pFileAccess,
|
| if (!RebuildCrossRef())
|
| return FORMAT_ERROR;
|
|
|
| - bXRefRebuilt = TRUE;
|
| + bXRefRebuilt = true;
|
| m_LastXRefOffset = 0;
|
| }
|
| } else {
|
| if (!RebuildCrossRef())
|
| return FORMAT_ERROR;
|
|
|
| - bXRefRebuilt = TRUE;
|
| + bXRefRebuilt = true;
|
| }
|
| Error eRet = SetEncryptHandler();
|
| if (eRet != SUCCESS)
|
| @@ -323,13 +323,13 @@ bool CPDF_Parser::VerifyCrossRefV4() {
|
| return true;
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
|
| - if (!LoadCrossRefV4(xrefpos, 0, TRUE))
|
| - return FALSE;
|
| +bool CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
|
| + if (!LoadCrossRefV4(xrefpos, 0, true))
|
| + return false;
|
|
|
| m_pTrailer = LoadTrailerV4();
|
| if (!m_pTrailer)
|
| - return FALSE;
|
| + return false;
|
|
|
| int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
|
| if (xrefsize > 0 && xrefsize <= kMaxXRefSize)
|
| @@ -349,18 +349,18 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
|
| while (xrefpos) {
|
| // Check for circular references.
|
| if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
|
| - return FALSE;
|
| + return false;
|
|
|
| seen_xrefpos.insert(xrefpos);
|
|
|
| // SLOW ...
|
| CrossRefList.insert(CrossRefList.begin(), xrefpos);
|
| - LoadCrossRefV4(xrefpos, 0, TRUE);
|
| + LoadCrossRefV4(xrefpos, 0, true);
|
|
|
| std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
|
| LoadTrailerV4());
|
| if (!pDict)
|
| - return FALSE;
|
| + return false;
|
|
|
| xrefpos = GetDirectInteger(pDict.get(), "Prev");
|
|
|
| @@ -371,26 +371,26 @@ FX_BOOL CPDF_Parser::LoadAllCrossRefV4(FX_FILESIZE xrefpos) {
|
| }
|
|
|
| for (size_t i = 0; i < CrossRefList.size(); ++i) {
|
| - if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
|
| - return FALSE;
|
| + if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false))
|
| + return false;
|
| if (i == 0 && !VerifyCrossRefV4())
|
| - return FALSE;
|
| + return false;
|
| }
|
| - return TRUE;
|
| + return true;
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
|
| - uint32_t dwObjCount) {
|
| +bool CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
|
| + uint32_t dwObjCount) {
|
| if (!LoadLinearizedCrossRefV4(xrefpos, dwObjCount))
|
| - return FALSE;
|
| + return false;
|
|
|
| m_pTrailer = LoadTrailerV4();
|
| if (!m_pTrailer)
|
| - return FALSE;
|
| + return false;
|
|
|
| int32_t xrefsize = GetDirectInteger(m_pTrailer, "Size");
|
| if (xrefsize == 0)
|
| - return FALSE;
|
| + return false;
|
|
|
| std::vector<FX_FILESIZE> CrossRefList;
|
| std::vector<FX_FILESIZE> XRefStreamList;
|
| @@ -404,18 +404,18 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
|
| while (xrefpos) {
|
| // Check for circular references.
|
| if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
|
| - return FALSE;
|
| + return false;
|
|
|
| seen_xrefpos.insert(xrefpos);
|
|
|
| // SLOW ...
|
| CrossRefList.insert(CrossRefList.begin(), xrefpos);
|
| - LoadCrossRefV4(xrefpos, 0, TRUE);
|
| + LoadCrossRefV4(xrefpos, 0, true);
|
|
|
| std::unique_ptr<CPDF_Dictionary, ReleaseDeleter<CPDF_Dictionary>> pDict(
|
| LoadTrailerV4());
|
| if (!pDict)
|
| - return FALSE;
|
| + return false;
|
|
|
| xrefpos = GetDirectInteger(pDict.get(), "Prev");
|
|
|
| @@ -426,14 +426,14 @@ FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV4(FX_FILESIZE xrefpos,
|
| }
|
|
|
| for (size_t i = 1; i < CrossRefList.size(); ++i) {
|
| - if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], FALSE))
|
| - return FALSE;
|
| + if (!LoadCrossRefV4(CrossRefList[i], XRefStreamList[i], false))
|
| + return false;
|
| }
|
| - return TRUE;
|
| + return true;
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
|
| - uint32_t dwObjCount) {
|
| +bool CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
|
| + uint32_t dwObjCount) {
|
| FX_FILESIZE dwStartPos = pos - m_pSyntax->m_HeaderOffset;
|
|
|
| m_pSyntax->RestorePos(dwStartPos);
|
| @@ -452,11 +452,11 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
|
| int32_t block_size = block == nBlocks - 1 ? count % 1024 : 1024;
|
| uint32_t dwReadSize = block_size * recordsize;
|
| if ((FX_FILESIZE)(dwStartPos + dwReadSize) > m_pSyntax->m_FileLen)
|
| - return FALSE;
|
| + return false;
|
|
|
| if (!m_pSyntax->ReadBlock(reinterpret_cast<uint8_t*>(buf.data()),
|
| dwReadSize)) {
|
| - return FALSE;
|
| + return false;
|
| }
|
|
|
| for (int32_t i = 0; i < block_size; i++) {
|
| @@ -470,7 +470,7 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
|
| if (offset == 0) {
|
| for (int32_t c = 0; c < 10; c++) {
|
| if (!std::isdigit(pEntry[c]))
|
| - return FALSE;
|
| + return false;
|
| }
|
| }
|
|
|
| @@ -488,12 +488,12 @@ FX_BOOL CPDF_Parser::LoadLinearizedCrossRefV4(FX_FILESIZE pos,
|
| }
|
| }
|
| m_pSyntax->RestorePos(SavedPos + count * recordsize);
|
| - return TRUE;
|
| + return true;
|
| }
|
|
|
| bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
|
| FX_FILESIZE streampos,
|
| - FX_BOOL bSkip) {
|
| + bool bSkip) {
|
| m_pSyntax->RestorePos(pos);
|
| if (m_pSyntax->GetKeyword() != "xref")
|
| return false;
|
| @@ -565,29 +565,29 @@ bool CPDF_Parser::LoadCrossRefV4(FX_FILESIZE pos,
|
| }
|
| m_pSyntax->RestorePos(SavedPos + count * recordsize);
|
| }
|
| - return !streampos || LoadCrossRefV5(&streampos, FALSE);
|
| + return !streampos || LoadCrossRefV5(&streampos, false);
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) {
|
| - if (!LoadCrossRefV5(&xrefpos, TRUE))
|
| - return FALSE;
|
| +bool CPDF_Parser::LoadAllCrossRefV5(FX_FILESIZE xrefpos) {
|
| + if (!LoadCrossRefV5(&xrefpos, true))
|
| + return false;
|
|
|
| std::set<FX_FILESIZE> seen_xrefpos;
|
| while (xrefpos) {
|
| seen_xrefpos.insert(xrefpos);
|
| - if (!LoadCrossRefV5(&xrefpos, FALSE))
|
| - return FALSE;
|
| + if (!LoadCrossRefV5(&xrefpos, false))
|
| + return false;
|
|
|
| // Check for circular references.
|
| if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
|
| - return FALSE;
|
| + return false;
|
| }
|
| m_ObjectStreamMap.clear();
|
| - m_bXRefStream = TRUE;
|
| - return TRUE;
|
| + m_bXRefStream = true;
|
| + return true;
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::RebuildCrossRef() {
|
| +bool CPDF_Parser::RebuildCrossRef() {
|
| m_ObjectInfo.clear();
|
| m_SortedOffset.clear();
|
| if (m_pTrailer) {
|
| @@ -954,35 +954,35 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
|
| return m_pTrailer && !m_ObjectInfo.empty();
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
|
| +bool CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, bool bMainXRef) {
|
| std::unique_ptr<CPDF_Object> pObject(
|
| ParseIndirectObjectAt(m_pDocument, *pos, 0));
|
| if (!pObject)
|
| - return FALSE;
|
| + return false;
|
|
|
| CPDF_Object* pUnownedObject = pObject.get();
|
|
|
| if (m_pDocument) {
|
| CPDF_Dictionary* pRootDict = m_pDocument->GetRoot();
|
| if (pRootDict && pRootDict->GetObjNum() == pObject->m_ObjNum)
|
| - return FALSE;
|
| + return false;
|
| // Takes ownership of object (std::move someday).
|
| uint32_t objnum = pObject->m_ObjNum;
|
| if (!m_pDocument->ReplaceIndirectObjectIfHigherGeneration(
|
| objnum, pObject.release())) {
|
| - return FALSE;
|
| + return false;
|
| }
|
| }
|
|
|
| CPDF_Stream* pStream = pUnownedObject->AsStream();
|
| if (!pStream)
|
| - return FALSE;
|
| + return false;
|
|
|
| CPDF_Dictionary* pDict = pStream->GetDict();
|
| *pos = pDict->GetIntegerFor("Prev");
|
| int32_t size = pDict->GetIntegerFor("Size");
|
| if (size < 0)
|
| - return FALSE;
|
| + return false;
|
|
|
| CPDF_Dictionary* pNewTrailer = ToDictionary(pDict->Clone());
|
| if (bMainXRef) {
|
| @@ -1015,7 +1015,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
|
|
|
| pArray = pDict->GetArrayFor("W");
|
| if (!pArray)
|
| - return FALSE;
|
| + return false;
|
|
|
| CFX_ArrayTemplate<uint32_t> WidthArray;
|
| FX_SAFE_UINT32 dwAccWidth = 0;
|
| @@ -1025,7 +1025,7 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
|
| }
|
|
|
| if (!dwAccWidth.IsValid() || WidthArray.GetSize() < 3)
|
| - return FALSE;
|
| + return false;
|
|
|
| uint32_t totalWidth = dwAccWidth.ValueOrDie();
|
| CPDF_StreamAcc acc;
|
| @@ -1086,14 +1086,14 @@ FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE* pos, FX_BOOL bMainXRef) {
|
| m_SortedOffset.insert(offset);
|
| } else {
|
| if (offset < 0 || !IsValidObjectNumber(offset))
|
| - return FALSE;
|
| + return false;
|
| m_ObjectInfo[offset].type = 255;
|
| }
|
| }
|
| }
|
| segindex += count;
|
| }
|
| - return TRUE;
|
| + return true;
|
| }
|
|
|
| CPDF_Array* CPDF_Parser::GetIDArray() {
|
| @@ -1145,7 +1145,7 @@ CPDF_Object* CPDF_Parser::ParseIndirectObject(
|
| return nullptr;
|
|
|
| ScopedFileStream file(FX_CreateMemoryStream(
|
| - (uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), FALSE));
|
| + (uint8_t*)pObjStream->GetData(), (size_t)pObjStream->GetSize(), false));
|
| CPDF_SyntaxParser syntax;
|
| syntax.InitParser(file.get(), 0);
|
| const int32_t offset = GetStreamFirst(pObjStream);
|
| @@ -1224,7 +1224,7 @@ void CPDF_Parser::GetIndirectBinary(uint32_t objnum,
|
| const uint8_t* pData = pObjStream->GetData();
|
| uint32_t totalsize = pObjStream->GetSize();
|
| ScopedFileStream file(
|
| - FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, FALSE));
|
| + FX_CreateMemoryStream((uint8_t*)pData, (size_t)totalsize, false));
|
|
|
| CPDF_SyntaxParser syntax;
|
| syntax.InitParser(file.get(), 0);
|
| @@ -1290,16 +1290,16 @@ void CPDF_Parser::GetIndirectBinary(uint32_t objnum,
|
| }
|
|
|
| FX_FILESIZE nextoff = *it;
|
| - FX_BOOL bNextOffValid = FALSE;
|
| + bool bNextOffValid = false;
|
| if (nextoff != pos) {
|
| m_pSyntax->RestorePos(nextoff);
|
| word = m_pSyntax->GetNextWord(&bIsNumber);
|
| if (word == "xref") {
|
| - bNextOffValid = TRUE;
|
| + bNextOffValid = true;
|
| } else if (bIsNumber) {
|
| word = m_pSyntax->GetNextWord(&bIsNumber);
|
| if (bIsNumber && m_pSyntax->GetKeyword() == "obj") {
|
| - bNextOffValid = TRUE;
|
| + bNextOffValid = true;
|
| }
|
| }
|
| }
|
| @@ -1438,8 +1438,8 @@ uint32_t CPDF_Parser::GetPermissions() const {
|
| return dwPermission;
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
|
| - uint32_t offset) {
|
| +bool CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
|
| + uint32_t offset) {
|
| m_pSyntax->InitParser(pFileAccess, offset);
|
| m_pSyntax->RestorePos(m_pSyntax->m_HeaderOffset + 9);
|
|
|
| @@ -1447,22 +1447,22 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
|
| bool bIsNumber;
|
| CFX_ByteString word = m_pSyntax->GetNextWord(&bIsNumber);
|
| if (!bIsNumber)
|
| - return FALSE;
|
| + return false;
|
|
|
| uint32_t objnum = FXSYS_atoui(word.c_str());
|
| word = m_pSyntax->GetNextWord(&bIsNumber);
|
| if (!bIsNumber)
|
| - return FALSE;
|
| + return false;
|
|
|
| uint32_t gennum = FXSYS_atoui(word.c_str());
|
| if (m_pSyntax->GetKeyword() != "obj") {
|
| m_pSyntax->RestorePos(SavedPos);
|
| - return FALSE;
|
| + return false;
|
| }
|
|
|
| m_pLinearized = m_pSyntax->GetObject(nullptr, objnum, gennum, true);
|
| if (!m_pLinearized)
|
| - return FALSE;
|
| + return false;
|
|
|
| CPDF_Dictionary* pDict = m_pLinearized->GetDict();
|
| if (pDict && pDict->GetObjectFor("Linearized")) {
|
| @@ -1472,11 +1472,11 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
|
| if (!pLen) {
|
| m_pLinearized->Release();
|
| m_pLinearized = nullptr;
|
| - return FALSE;
|
| + return false;
|
| }
|
|
|
| if (pLen->GetInteger() != (int)pFileAccess->GetSize())
|
| - return FALSE;
|
| + return false;
|
|
|
| if (CPDF_Number* pNo = ToNumber(pDict->GetObjectFor("P")))
|
| m_dwFirstPageNo = pNo->GetInteger();
|
| @@ -1484,11 +1484,11 @@ FX_BOOL CPDF_Parser::IsLinearizedFile(IFX_SeekableReadStream* pFileAccess,
|
| if (CPDF_Number* pTable = ToNumber(pDict->GetObjectFor("T")))
|
| m_LastXRefOffset = pTable->GetInteger();
|
|
|
| - return TRUE;
|
| + return true;
|
| }
|
| m_pLinearized->Release();
|
| m_pLinearized = nullptr;
|
| - return FALSE;
|
| + return false;
|
| }
|
|
|
| CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
|
| @@ -1496,7 +1496,7 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
|
| CPDF_Document* pDocument) {
|
| ASSERT(!m_bHasParsed);
|
|
|
| - m_bXRefStream = FALSE;
|
| + m_bXRefStream = false;
|
| m_LastXRefOffset = 0;
|
| m_bOwnFileRead = true;
|
|
|
| @@ -1513,13 +1513,13 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
|
|
|
| FX_FILESIZE dwFirstXRefOffset = m_pSyntax->SavePos();
|
|
|
| - FX_BOOL bXRefRebuilt = FALSE;
|
| - FX_BOOL bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, FALSE);
|
| - if (!bLoadV4 && !LoadCrossRefV5(&dwFirstXRefOffset, TRUE)) {
|
| + bool bXRefRebuilt = false;
|
| + bool bLoadV4 = LoadCrossRefV4(dwFirstXRefOffset, 0, false);
|
| + if (!bLoadV4 && !LoadCrossRefV5(&dwFirstXRefOffset, true)) {
|
| if (!RebuildCrossRef())
|
| return FORMAT_ERROR;
|
|
|
| - bXRefRebuilt = TRUE;
|
| + bXRefRebuilt = true;
|
| m_LastXRefOffset = 0;
|
| }
|
|
|
| @@ -1573,23 +1573,23 @@ CPDF_Parser::Error CPDF_Parser::StartLinearizedParse(
|
| return SUCCESS;
|
| }
|
|
|
| -FX_BOOL CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) {
|
| - if (!LoadCrossRefV5(&xrefpos, FALSE))
|
| - return FALSE;
|
| +bool CPDF_Parser::LoadLinearizedAllCrossRefV5(FX_FILESIZE xrefpos) {
|
| + if (!LoadCrossRefV5(&xrefpos, false))
|
| + return false;
|
|
|
| std::set<FX_FILESIZE> seen_xrefpos;
|
| while (xrefpos) {
|
| seen_xrefpos.insert(xrefpos);
|
| - if (!LoadCrossRefV5(&xrefpos, FALSE))
|
| - return FALSE;
|
| + if (!LoadCrossRefV5(&xrefpos, false))
|
| + return false;
|
|
|
| // Check for circular references.
|
| if (pdfium::ContainsKey(seen_xrefpos, xrefpos))
|
| - return FALSE;
|
| + return false;
|
| }
|
| m_ObjectStreamMap.clear();
|
| - m_bXRefStream = TRUE;
|
| - return TRUE;
|
| + m_bXRefStream = true;
|
| + return true;
|
| }
|
|
|
| CPDF_Parser::Error CPDF_Parser::LoadLinearizedMainXRefTable() {
|
|
|