diff options
Diffstat (limited to 'src/string.hh')
| -rw-r--r-- | src/string.hh | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/string.hh b/src/string.hh index 74fbb51a..be140888 100644 --- a/src/string.hh +++ b/src/string.hh @@ -231,7 +231,9 @@ inline StringView StringOps<Type, CharType>::substr(ByteCount from, ByteCount le { if (length < 0) length = INT_MAX; - return StringView{ type().data() + (int)from, std::min(type().length() - from, length) }; + const auto str_len = type().length(); + kak_assert(from >= 0 and from <= str_len); + return StringView{ type().data() + (int)from, std::min(str_len - from, length) }; } template<typename Type, typename CharType> |
