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

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: add root object checking Created 5 years, 1 month 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..a71adc8b48649d943a2a68dd0270f6eff3c4351a 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())
jun_fang 2015/12/01 15:25:18 please check the comment at line 1610.
Wei Li 2015/12/01 18:45:03 Acknowledged.
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 && GetRootObjNum() > 0 && m_CrossRef.GetSize() > 0;
jun_fang 2015/12/01 15:20:58 The newly added condition ' GetRootObjNum() > 0' w
Wei Li 2015/12/01 18:45:03 I reverted to my original change. I think more tho
}
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) {
jun_fang 2015/12/01 14:56:20 It's a trigger to rebuild cross reference table wh
Wei Li 2015/12/01 18:45:03 I saw this. But RebuildCrossRef function is used a
+ if (GetRootObjNum() == 0) {
ReleaseEncryptHandler();
- RebuildCrossRef();
- RootObjNum = GetRootObjNum();
- if (RootObjNum == 0) {
+ if (!RebuildCrossRef())
jun_fang 2015/12/01 15:20:58 Based on the analysis, I prefer to keep left code
Wei Li 2015/12/01 18:45:03 I would prefer keeping the check here as the comme
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