Preprocessor:removeParentheses: fixed potential buffer access out of bounds, if find returns std::string::npos.

This commit is contained in:
orbitcowboy 2013-12-09 01:40:51 -08:00
parent 4e7594748d
commit 4fbe15c866
1 changed files with 5 additions and 2 deletions

View File

@ -819,8 +819,11 @@ std::string Preprocessor::removeParentheses(const std::string &str)
--ind;
if (ind == 0) {
if (i == line.length() - 1) {
line[line.find('(')] = ' ';
line.erase(line.length() - 1);
const std::string::size_type posIndx = line.find('(');
if (posIndx != std::string::npos) {
line[posIndx] = ' ';
line.erase(line.length() - 1);
}
}
break;
}