A bit more tolerant check to return itself in String::substr().

This commit is contained in:
Tsuda Kageyu
2016-11-26 13:05:14 +09:00
parent 7871afec37
commit d3062f3af4
2 changed files with 3 additions and 1 deletions

View File

@ -447,7 +447,7 @@ bool String::startsWith(const String &s) const
String String::substr(unsigned int position, unsigned int n) const
{
if(position == 0 && n == size())
if(position == 0 && n >= size())
return *this;
else
return String(d->data.substr(position, n));