From 193e6ca5e48ee99e620f0e7546f1407ba1a20323 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 14 Mar 2017 15:53:36 -0700 Subject: Add IndexInBounds() convenience routine. Avoid writing |Type| in CollectionSize() so that index type can change without rewriting conditions. Change-Id: I40c94ca39148b379908760ba9b861114b88af7bb Reviewed-on: https://pdfium-review.googlesource.com/3056 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- xfa/fde/tto/fde_textout.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'xfa/fde/tto/fde_textout.cpp') diff --git a/xfa/fde/tto/fde_textout.cpp b/xfa/fde/tto/fde_textout.cpp index c9f5ec84ef..f816176841 100644 --- a/xfa/fde/tto/fde_textout.cpp +++ b/xfa/fde/tto/fde_textout.cpp @@ -775,10 +775,7 @@ int32_t CFDE_TTOLine::GetSize() const { } FDE_TTOPIECE* CFDE_TTOLine::GetPtrAt(int32_t index) { - if (index < 0 || index >= pdfium::CollectionSize(m_pieces)) - return nullptr; - - return &m_pieces[index]; + return pdfium::IndexInBounds(m_pieces, index) ? &m_pieces[index] : nullptr; } void CFDE_TTOLine::RemoveLast(int32_t icount) { -- cgit v1.2.3