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

Unified Diff: core/fpdfapi/parser/cpdf_document.cpp

Issue 2491583002: Fix receiving page, if it have not obj num. (Closed)
Patch Set: Fix review issues Created 4 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/fpdfapi/parser/cpdf_document_unittest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfapi/parser/cpdf_document.cpp
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp
index 1c73ce1015b168f633a2a4b5362a1229ee98d39a..678839411864a52e86ca65ec561e4e79645018b7 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -492,9 +492,18 @@ CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
if (!pPages)
return nullptr;
+ if (iPage - m_iNextPageToTraverse + 1 <= 0) {
+ // This can happen when the page does not have an object number. On repeated
+ // calls to this function for the same page index, this condition causes
+ // TraversePDFPages() to incorrectly return nullptr.
+ // Example "testing/corpus/fx/other/jetman_std.pdf"
+ // We should restart traversing in this case.
+ // TODO(art-snake): optimize this.
+ ResetTraversal();
+ }
+ int nPagesToGo = iPage - m_iNextPageToTraverse + 1;
if (m_pTreeTraversal.empty())
m_pTreeTraversal.push_back(std::make_pair(pPages, 0));
- int nPagesToGo = iPage - m_iNextPageToTraverse + 1;
CPDF_Dictionary* pPage = TraversePDFPages(iPage, &nPagesToGo, 0);
m_iNextPageToTraverse = iPage + 1;
return pPage;
« no previous file with comments | « no previous file | core/fpdfapi/parser/cpdf_document_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698