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/page | |
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/page')
-rw-r--r-- | core/fpdfapi/page/cpdf_pageobjectlist.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/core/fpdfapi/page/cpdf_pageobjectlist.cpp b/core/fpdfapi/page/cpdf_pageobjectlist.cpp index 02b590e413..5c30fe9877 100644 --- a/core/fpdfapi/page/cpdf_pageobjectlist.cpp +++ b/core/fpdfapi/page/cpdf_pageobjectlist.cpp @@ -10,7 +10,5 @@ #include "third_party/base/stl_util.h" CPDF_PageObject* CPDF_PageObjectList::GetPageObjectByIndex(int index) { - if (index < 0 || index >= pdfium::CollectionSize<int>(*this)) - return nullptr; - return (*this)[index].get(); + return pdfium::IndexInBounds(*this, index) ? (*this)[index].get() : nullptr; } |