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/fpdftext | |
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/fpdftext')
-rw-r--r-- | core/fpdftext/cpdf_textpage.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/core/fpdftext/cpdf_textpage.cpp b/core/fpdftext/cpdf_textpage.cpp index 7a89b24171..1eab19f4f1 100644 --- a/core/fpdftext/cpdf_textpage.cpp +++ b/core/fpdftext/cpdf_textpage.cpp @@ -378,10 +378,7 @@ CFX_WideString CPDF_TextPage::GetTextByRect(const CFX_FloatRect& rect) const { } void CPDF_TextPage::GetCharInfo(int index, FPDF_CHAR_INFO* info) const { - if (!m_bIsParsed) - return; - - if (index < 0 || index >= pdfium::CollectionSize<int>(m_CharList)) + if (!m_bIsParsed || !pdfium::IndexInBounds(m_CharList, index)) return; const PAGECHAR_INFO& charinfo = m_CharList[index]; @@ -496,10 +493,7 @@ void CPDF_TextPage::GetRect(int rectIndex, float& top, float& right, float& bottom) const { - if (!m_bIsParsed) - return; - - if (rectIndex < 0 || rectIndex >= pdfium::CollectionSize<int>(m_SelRects)) + if (!m_bIsParsed || !pdfium::IndexInBounds(m_SelRects, rectIndex)) return; left = m_SelRects[rectIndex].left; |