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

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

Issue 2491583002: Fix receiving page, if it have not obj num. (Closed)
Patch Set: Fix signed/unsigned comparison 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
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..b2a3d82e216165c3b3b2108bd485590205f3e60e 100644
--- a/core/fpdfapi/parser/cpdf_document.cpp
+++ b/core/fpdfapi/parser/cpdf_document.cpp
@@ -492,9 +492,20 @@ CPDF_Dictionary* CPDF_Document::GetPage(int iPage) {
if (!pPages)
return nullptr;
+ int nPagesToGo = iPage - m_iNextPageToTraverse + 1;
+ if (nPagesToGo <= 0) {
npm 2016/11/09 20:32:56 This could also happen in cases where we just skip
snake 2016/11/09 20:46:47 I see this before. I will check this case.
+ // This can be happened, when page have not objNum.
Lei Zhang 2016/11/09 20:19:41 Rephrase: "This can happen when the page does not
snake 2016/11/09 20:30:41 Done.
+ // And on call GetPage with page index, which was traversed before,
+ // nPagesToGo will be less or zero and TraversePDFPages returns nullptr;
+ // Example "testing\corpus\fx\other\jetman_std.pdf"
Lei Zhang 2016/11/09 20:19:41 I would prefer to use "/" for path separator, sinc
snake 2016/11/09 20:30:41 Done.
+ // We should restart traversing in this case.
+ // TODO(art-snake): optimize this.
npm 2016/11/09 20:32:56 To optimize, we could store the dict pointer when
snake 2016/11/09 20:46:47 I should think about this. May be more better gene
npm 2016/11/09 21:55:03 AFAIK objNum is 0 for CPDF_Object when its direct
snake 2016/11/09 22:39:47 Anyway, i will do this in other CL.
+ m_pTreeTraversal.clear();
npm 2016/11/09 20:32:56 nit: use ResetTraversal() instead.
snake 2016/11/09 20:46:47 Done.
+ m_iNextPageToTraverse = 0;
+ nPagesToGo = iPage - m_iNextPageToTraverse + 1;
Lei Zhang 2016/11/09 20:19:41 nit: You already know |m_iNextPageToTraverse| is 0
snake 2016/11/09 20:30:41 Done.
+ }
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') | core/fpdfapi/parser/cpdf_document_unittest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698