mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-06 22:30:07 -05:00
string: Tolerate SUBSTRING length exceeding end index
string SUBSTRING command now ignores length if it points past end of string and uses end of string instead. String SUBSTRING tests now cover more corner cases.
This commit is contained in:
@@ -711,12 +711,10 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
|
||||
this->SetError(ostr.str());
|
||||
return false;
|
||||
}
|
||||
int leftOverLength = intStringLength - begin;
|
||||
if ( end < -1 || end > leftOverLength )
|
||||
if ( end < -1 )
|
||||
{
|
||||
cmOStringStream ostr;
|
||||
ostr << "end index: " << end << " is out of range -1 - "
|
||||
<< leftOverLength;
|
||||
ostr << "end index: " << end << " should be -1 or greater";
|
||||
this->SetError(ostr.str());
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user