#6122 segmentation fault (invalid code) in in valueFlowForLoop2. Simple fix and testcase.

This commit is contained in:
Alexander Mai 2014-09-02 19:41:50 +02:00
parent 45dc4ca6be
commit a632f68345
2 changed files with 5 additions and 1 deletions

View File

@ -1266,7 +1266,7 @@ static bool valueFlowForLoop2(const Token *tok,
tokens.pop();
if (!t)
continue;
if (t->str() == "=" && programMemory.find(t->astOperand1()->varId()) != programMemory.end())
if (t->str() == "=" && t->astOperand1() && programMemory.find(t->astOperand1()->varId()) != programMemory.end())
// TODO: investigate what variable is assigned.
return false;
tokens.push(t->astOperand1());

View File

@ -1267,6 +1267,10 @@ private:
// #6106
code = " f { int i ; b2 , [ ] ( for ( i = 0 ; ; ) ) }";
valueOfTok(code, "*");
// 6122 survive garbage code
code = "; { int i ; for ( i = 0 ; = 123 ; ) - ; }";
valueOfTok(code, "*");
}
};