ValueFlow: Fix crash for lambda function

This commit is contained in:
Daniel Marjamäki 2014-08-27 17:27:34 +02:00
parent 2dc3945017
commit eeeb8aa0a7
1 changed files with 6 additions and 0 deletions

View File

@ -667,6 +667,12 @@ static bool valueFlowForward(Token * const startToken,
--indentlevel; --indentlevel;
if (indentlevel == 0 && isReturn(tok2) && Token::simpleMatch(tok2->link()->previous(), ") {")) { if (indentlevel == 0 && isReturn(tok2) && Token::simpleMatch(tok2->link()->previous(), ") {")) {
const Token *condition = tok2->link()->linkAt(-1)->astOperand2(); const Token *condition = tok2->link()->linkAt(-1)->astOperand2();
if (!condition) {
if (settings->debugwarnings)
bailout(tokenlist, errorLogger, tok2, "variable " + var->name() + " valueFlowForward, bailing out since it's unknown if conditional return is executed");
return false;
}
bool bailoutflag = false; bool bailoutflag = false;
for (std::list<ValueFlow::Value>::const_iterator it = values.begin(); it != values.end(); ++it) { for (std::list<ValueFlow::Value>::const_iterator it = values.begin(); it != values.end(); ++it) {
if (conditionIsTrue(condition, getProgramMemory(condition->astParent(), varid, *it))) { if (conditionIsTrue(condition, getProgramMemory(condition->astParent(), varid, *it))) {