From ddb9b7cdd19b63a81c4a094239e85f84acefaa17 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Fri, 11 Aug 2017 16:20:32 -0400 Subject: Add checks of index operations on string classes Specifically the index parameter passed in to GetAt(), SetAt() and operator[] are now being tested to be in bounds. BUG=chromium:752480, pdfium:828 Change-Id: I9e94d58c98a8eaaaae53cd0e3ffe2123ea17d8c4 Reviewed-on: https://pdfium-review.googlesource.com/10651 Commit-Queue: Ryan Harrison Reviewed-by: Tom Sepez --- core/fxcrt/cfx_bytestring.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'core/fxcrt/cfx_bytestring.cpp') diff --git a/core/fxcrt/cfx_bytestring.cpp b/core/fxcrt/cfx_bytestring.cpp index c29d24affd..0aba3be12a 100644 --- a/core/fxcrt/cfx_bytestring.cpp +++ b/core/fxcrt/cfx_bytestring.cpp @@ -694,14 +694,10 @@ FX_STRSIZE CFX_ByteString::Replace(const CFX_ByteStringC& pOld, return nCount; } -void CFX_ByteString::SetAt(FX_STRSIZE nIndex, char ch) { - if (!m_pData) { - return; - } - ASSERT(nIndex >= 0); - ASSERT(nIndex < m_pData->m_nDataLength); +void CFX_ByteString::SetAt(FX_STRSIZE index, char c) { + ASSERT(index >= 0 && index < GetLength()); ReallocBeforeWrite(m_pData->m_nDataLength); - m_pData->m_String[nIndex] = ch; + m_pData->m_String[index] = c; } CFX_WideString CFX_ByteString::UTF8Decode() const { -- cgit v1.2.3