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/fgas/layout/fgas_rtfbreak.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'xfa/fgas/layout/fgas_rtfbreak.cpp') diff --git a/xfa/fgas/layout/fgas_rtfbreak.cpp b/xfa/fgas/layout/fgas_rtfbreak.cpp index 37822140c3..68c04a7f64 100644 --- a/xfa/fgas/layout/fgas_rtfbreak.cpp +++ b/xfa/fgas/layout/fgas_rtfbreak.cpp @@ -805,8 +805,9 @@ const CFX_BreakPiece* CFX_RTFBreak::GetBreakPieceUnstable(int32_t index) const { const std::vector& pRTFPieces = m_RTFLine[m_iReadyLineIndex].m_LinePieces; - if (index < 0 || index >= pdfium::CollectionSize(pRTFPieces)) + if (!pdfium::IndexInBounds(pRTFPieces, index)) return nullptr; + return &pRTFPieces[index]; } -- cgit v1.2.3