diff options
author | Tom Sepez <tsepez@chromium.org> | 2017-03-14 15:53:36 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-03-15 00:03:38 +0000 |
commit | 193e6ca5e48ee99e620f0e7546f1407ba1a20323 (patch) | |
tree | 11d920c59a89247d28fe590d77ab6d6a9ce37a0c /core/fpdfapi/parser/cpdf_document.cpp | |
parent | cd5139a291113f177d3494990efbcaf388d1f3bf (diff) | |
download | pdfium-193e6ca5e48ee99e620f0e7546f1407ba1a20323.tar.xz |
Add IndexInBounds() convenience routine.
Avoid writing |Type| in CollectionSize<Type>() so that index
type can change without rewriting conditions.
Change-Id: I40c94ca39148b379908760ba9b861114b88af7bb
Reviewed-on: https://pdfium-review.googlesource.com/3056
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fpdfapi/parser/cpdf_document.cpp')
-rw-r--r-- | core/fpdfapi/parser/cpdf_document.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/fpdfapi/parser/cpdf_document.cpp b/core/fpdfapi/parser/cpdf_document.cpp index ed88a4f82a..8ff9e66506 100644 --- a/core/fpdfapi/parser/cpdf_document.cpp +++ b/core/fpdfapi/parser/cpdf_document.cpp @@ -477,10 +477,10 @@ bool CPDF_Document::IsPageLoaded(int iPage) const { } CPDF_Dictionary* CPDF_Document::GetPage(int iPage) { - if (iPage < 0 || iPage >= pdfium::CollectionSize<int>(m_PageList)) + if (!pdfium::IndexInBounds(m_PageList, iPage)) return nullptr; - if (m_bLinearized && (iPage == m_iFirstPageNo)) { + if (m_bLinearized && iPage == m_iFirstPageNo) { if (CPDF_Dictionary* pDict = ToDictionary(GetOrParseIndirectObject(m_dwFirstPageObjNum))) { return pDict; @@ -586,7 +586,7 @@ int CPDF_Document::GetPageIndex(uint32_t objnum) { int found_index = FindPageIndex(pPages, &skip_count, objnum, &start_index); // Corrupt page tree may yield out-of-range results. - if (found_index < 0 || found_index >= pdfium::CollectionSize<int>(m_PageList)) + if (!pdfium::IndexInBounds(m_PageList, found_index)) return -1; m_PageList[found_index] = objnum; |