summaryrefslogtreecommitdiff
path: root/core/include/fpdfapi/fpdf_parser.h
diff options
context:
space:
mode:
authorWei Li <weili@chromium.org>2016-01-14 12:29:02 -0800
committerWei Li <weili@chromium.org>2016-01-14 12:29:02 -0800
commit215816b7450a577e186cc0e5f1634c4c6610b86b (patch)
treea7dee02e32643f5032ed8a07191dbaf532deedf0 /core/include/fpdfapi/fpdf_parser.h
parent652bd5f333145c39b2e14eee49c654d9501beebf (diff)
downloadpdfium-215816b7450a577e186cc0e5f1634c4c6610b86b.tar.xz
Merge to XFA: Correct the way to count pages and to avoid infinite loop
BUG=pdfium:360 TBR=thestig@chromium.org Review URL: https://codereview.chromium.org/1585823003 . (cherry picked from commit 5d5d9fe7bd1c9566b9d6570015b7c60894d9fc0c) Review URL: https://codereview.chromium.org/1583073004 .
Diffstat (limited to 'core/include/fpdfapi/fpdf_parser.h')
-rw-r--r--core/include/fpdfapi/fpdf_parser.h18
1 files changed, 17 insertions, 1 deletions
diff --git a/core/include/fpdfapi/fpdf_parser.h b/core/include/fpdfapi/fpdf_parser.h
index fda4557119..bdddfc37d7 100644
--- a/core/include/fpdfapi/fpdf_parser.h
+++ b/core/include/fpdfapi/fpdf_parser.h
@@ -61,6 +61,20 @@ inline bool PDFCharIsLineEnding(uint8_t c) {
return c == '\r' || c == '\n';
}
+template <typename T>
+class ScopedSetInsertion {
+ public:
+ ScopedSetInsertion(std::set<T>* org_set, T elem)
+ : m_Set(org_set), m_Entry(elem) {
+ m_Set->insert(m_Entry);
+ }
+ ~ScopedSetInsertion() { m_Set->erase(m_Entry); }
+
+ private:
+ std::set<T>* const m_Set;
+ const T m_Entry;
+};
+
// Indexed by 8-bit char code, contains unicode code points.
extern const FX_WORD PDFDocEncoding[256];
@@ -168,7 +182,9 @@ class CPDF_Document : public CFX_PrivateData, public CPDF_IndirectObjectHolder {
CFX_DWordArray m_PageList;
- int _GetPageCount() const;
+ // Retrieve page count information by getting count value from the tree nodes
+ // or walking through the tree nodes to calculate it.
+ int RetrievePageCount() const;
CPDF_Dictionary* _FindPDFPage(CPDF_Dictionary* pPages,
int iPage,
int nPagesToGo,