Merge pull request #765 from Dmitry-Me/checkFormatBeforeSplitting

Check string has expected format before processing it
This commit is contained in:
orbitcowboy 2016-01-20 15:07:28 +01:00
commit ad01a89e05
1 changed files with 6 additions and 2 deletions

View File

@ -181,9 +181,13 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
temp.append(1, c);
}
const std::string::size_type colonPos = temp.find(':');
if (colonPos == std::string::npos)
throw InternalError(0, "Internal Error: No colon found in <filename:line> pattern");
ErrorLogger::ErrorMessage::FileLocation loc;
loc.setfile(temp.substr(temp.find(':') + 1));
temp = temp.substr(0, temp.find(':'));
loc.setfile(temp.substr(colonPos + 1));
temp = temp.substr(0, colonPos);
std::istringstream fiss(temp);
fiss >> loc.line;