diff --git a/src/lol/base/string.h b/src/lol/base/string.h index b66b82cd..0d0bd51e 100644 --- a/src/lol/base/string.h +++ b/src/lol/base/string.h @@ -115,11 +115,13 @@ public: ((Super &)*this).Last() = '\0'; } - String Sub(int start, int count) const + String Sub(int start, int count = -1) const { ASSERT(start >= 0); - ASSERT(count >= 0); - ASSERT(start + count <= Count()); + if (start >= Count()) + return String(); + if (count < 0 || count >= Count() - start) + count = Count() - start; return String(&(*this)[start], count); }