diff options
author | tsepez <tsepez@chromium.org> | 2016-05-11 17:35:35 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-05-11 17:35:35 -0700 |
commit | f7fe678a4ada859a2e4fbbeeb0b1dff5b5887227 (patch) | |
tree | 271f61e203bcb7026db6b4936668f51f7f5e0de8 /core/fxcrt/fx_basic_bstring.cpp | |
parent | 94dfd56acc7ceb2acfc2e5c7ae516e34b160ea15 (diff) | |
download | pdfium-f7fe678a4ada859a2e4fbbeeb0b1dff5b5887227.tar.xz |
Add much-needed Find() method for CFX_*StringC
BUG=pdfium:493
Review-Url: https://codereview.chromium.org/1968233002
Diffstat (limited to 'core/fxcrt/fx_basic_bstring.cpp')
-rw-r--r-- | core/fxcrt/fx_basic_bstring.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/core/fxcrt/fx_basic_bstring.cpp b/core/fxcrt/fx_basic_bstring.cpp index cd7b616fbe..18e240bc84 100644 --- a/core/fxcrt/fx_basic_bstring.cpp +++ b/core/fxcrt/fx_basic_bstring.cpp @@ -673,11 +673,12 @@ FX_STRSIZE CFX_ByteString::Find(FX_CHAR ch, FX_STRSIZE nStart) const { if (!m_pData) return -1; - if (nStart >= m_pData->m_nDataLength) + if (nStart < 0 || nStart >= m_pData->m_nDataLength) return -1; - const FX_CHAR* pStr = FXSYS_strchr(m_pData->m_String + nStart, ch); - return pStr ? (int)(pStr - m_pData->m_String) : -1; + const FX_CHAR* pStr = static_cast<const FX_CHAR*>( + memchr(m_pData->m_String + nStart, ch, m_pData->m_nDataLength - nStart)); + return pStr ? pStr - m_pData->m_String : -1; } FX_STRSIZE CFX_ByteString::ReverseFind(FX_CHAR ch) const { |