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

Unified Diff: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp

Issue 1476163002: Add basic checking for RebuildCrossRef (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: not checking root obj Created 5 years 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/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
index 2105635687edd0f3e6fe3f44ee6dff568e5b2508..d5664c29ab46c0dd09d090b776bea1c11094ffe9 100644
--- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
+++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp
@@ -247,12 +247,9 @@ FX_DWORD CPDF_Parser::StartParse(IFX_FileRead* pFileAccess,
}
FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- FX_DWORD RootObjNum = GetRootObjNum();
- if (RootObjNum == 0) {
+ if (GetRootObjNum() == 0) {
ReleaseEncryptHandler();
- RebuildCrossRef();
- RootObjNum = GetRootObjNum();
- if (RootObjNum == 0)
+ if (!RebuildCrossRef() || GetRootObjNum() == 0)
return PDFPARSE_ERROR_FORMAT;
dwRet = SetEncryptHandler();
@@ -975,7 +972,7 @@ FX_BOOL CPDF_Parser::RebuildCrossRef() {
m_SortedOffset.Add(offset);
}
FX_Free(buffer);
- return TRUE;
+ return m_pTrailer && m_CrossRef.GetSize() > 0;
}
FX_BOOL CPDF_Parser::LoadCrossRefV5(FX_FILESIZE pos,
@@ -1608,14 +1605,11 @@ FX_DWORD CPDF_Parser::StartAsynParse(IFX_FileRead* pFileAccess,
}
FXSYS_qsort(m_SortedOffset.GetData(), m_SortedOffset.GetSize(),
sizeof(FX_FILESIZE), CompareFileSize);
- FX_DWORD RootObjNum = GetRootObjNum();
- if (RootObjNum == 0) {
+ if (GetRootObjNum() == 0) {
ReleaseEncryptHandler();
- RebuildCrossRef();
- RootObjNum = GetRootObjNum();
- if (RootObjNum == 0) {
+ if (!RebuildCrossRef() || GetRootObjNum() == 0)
return PDFPARSE_ERROR_FORMAT;
- }
+
dwRet = SetEncryptHandler();
if (dwRet != PDFPARSE_ERROR_SUCCESS) {
return dwRet;
« no previous file with comments | « no previous file | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698