summaryrefslogtreecommitdiff
path: root/core/fxcrt/cfx_bytestring.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcrt/cfx_bytestring.h')
-rw-r--r--core/fxcrt/cfx_bytestring.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/fxcrt/cfx_bytestring.h b/core/fxcrt/cfx_bytestring.h
index 10675be7a5..a8a28169a5 100644
--- a/core/fxcrt/cfx_bytestring.h
+++ b/core/fxcrt/cfx_bytestring.h
@@ -84,6 +84,14 @@ class CFX_ByteString {
}
bool IsEmpty() const { return !GetLength(); }
+ bool IsValidIndex(FX_STRSIZE index) const {
+ return 0 <= index && index < GetLength();
+ }
+
+ bool IsValidLength(FX_STRSIZE length) const {
+ return 0 <= length && length <= GetLength();
+ }
+
int Compare(const CFX_ByteStringC& str) const;
bool EqualNoCase(const CFX_ByteStringC& str) const;
@@ -109,7 +117,7 @@ class CFX_ByteString {
const CFX_ByteString& operator+=(const CFX_ByteStringC& bstrc);
CharType operator[](const FX_STRSIZE index) const {
- ASSERT(index >= 0 && index < GetLength());
+ ASSERT(IsValidIndex(index));
return m_pData ? m_pData->m_String[index] : 0;
}