Check string has expected format before processing it

This commit is contained in:
Dmitry-Me 2016-01-20 16:46:15 +03:00
parent 2484a29916
commit 58541f7ffa
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;