diff options
Diffstat (limited to 'src/string.hh')
| -rw-r--r-- | src/string.hh | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/string.hh b/src/string.hh index 8dd51404..5e0446e2 100644 --- a/src/string.hh +++ b/src/string.hh @@ -150,11 +150,15 @@ inline CharCount StringView::char_count_to(ByteCount count) const inline StringView StringView::substr(ByteCount from, ByteCount length) const { + if (length < 0) + length = INT_MAX; return StringView{ m_data + (int)from, std::min(m_length - from, length) }; } inline StringView StringView::substr(CharCount from, CharCount length) const { + if (length < 0) + length = INT_MAX; auto beg = utf8::advance(begin(), end(), (int)from); return StringView{ beg, utf8::advance(beg, end(), length) }; } |
