diff options
author | Ryan Harrison <rharrison@chromium.org> | 2017-08-11 16:20:32 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-08-11 21:03:14 +0000 |
commit | ddb9b7cdd19b63a81c4a094239e85f84acefaa17 (patch) | |
tree | 8657940fb10d76a96ffe996cf17d70a1c65ca6de /core/fxcrt/cfx_widestring.h | |
parent | d27998f6526272a5b8732106aa9b75f724434aca (diff) | |
download | pdfium-ddb9b7cdd19b63a81c4a094239e85f84acefaa17.tar.xz |
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 <rharrison@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_widestring.h')
-rw-r--r-- | core/fxcrt/cfx_widestring.h | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/core/fxcrt/cfx_widestring.h b/core/fxcrt/cfx_widestring.h index ccb1e752f7..b49e898f32 100644 --- a/core/fxcrt/cfx_widestring.h +++ b/core/fxcrt/cfx_widestring.h @@ -101,15 +101,14 @@ class CFX_WideString { bool operator<(const CFX_WideString& str) const; - wchar_t GetAt(FX_STRSIZE nIndex) const { - return m_pData ? m_pData->m_String[nIndex] : 0; + wchar_t GetAt(FX_STRSIZE index) const { + ASSERT(index >= 0 && index < GetLength()); + return m_pData->m_String[index]; } - wchar_t operator[](FX_STRSIZE nIndex) const { - return m_pData ? m_pData->m_String[nIndex] : 0; - } + wchar_t operator[](FX_STRSIZE index) const { return GetAt(index); } - void SetAt(FX_STRSIZE nIndex, wchar_t ch); + void SetAt(FX_STRSIZE index, wchar_t c); int Compare(const wchar_t* str) const; int Compare(const CFX_WideString& str) const; |