Fix issue 8842: Crash in valueFlowTerminatingCondition on incomplete code (#1480)
This commit is contained in:
parent
e839001f3d
commit
f0c86b9d14
|
@ -1136,6 +1136,8 @@ static void valueFlowTerminatingCondition(TokenList *tokenlist, SymbolDatabase*
|
|||
const Variable * var = tok2->variable();
|
||||
if (!var)
|
||||
continue;
|
||||
if(!var->scope())
|
||||
continue;
|
||||
const Token * endToken = var->scope()->bodyEnd;
|
||||
if (!var->isLocal() && !var->isConst() && !var->isArgument()) {
|
||||
bail = true;
|
||||
|
|
|
@ -2693,6 +2693,16 @@ private:
|
|||
" return;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// 8842 crash
|
||||
check("class a {\n"
|
||||
" int b;\n"
|
||||
" c(b);\n"
|
||||
" void f() {\n"
|
||||
" if (b) return;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void multiConditionAlwaysTrue() {
|
||||
|
|
Loading…
Reference in New Issue