Fixed #583 (False positive: the nullpointer check doesn't handle goto properly)
This commit is contained in:
parent
4c32057180
commit
ad4ea01750
|
@ -1130,6 +1130,10 @@ void CheckOther::nullPointer()
|
||||||
--indentlevel2;
|
--indentlevel2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// goto destination..
|
||||||
|
else if (tok2->isName() && Token::simpleMatch(tok2->next(), ":"))
|
||||||
|
break;
|
||||||
|
|
||||||
// Reassignment of the struct
|
// Reassignment of the struct
|
||||||
else if (tok2->varId() == varid1)
|
else if (tok2->varId() == varid1)
|
||||||
{
|
{
|
||||||
|
@ -1194,6 +1198,10 @@ void CheckOther::nullPointer()
|
||||||
else if (tok1->str() == "{" ||
|
else if (tok1->str() == "{" ||
|
||||||
tok1->str() == "}")
|
tok1->str() == "}")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// goto destination..
|
||||||
|
else if (tok1->isName() && Token::simpleMatch(tok1->next(), ":"))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -532,6 +532,15 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkNullPointer("void foo(struct ABC *abc)\n"
|
||||||
|
"{\n"
|
||||||
|
" int *a = abc->a;\n"
|
||||||
|
"out:\n"
|
||||||
|
" if (!abc)\n"
|
||||||
|
" ;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// loops..
|
// loops..
|
||||||
checkNullPointer("void freeAbc(struct ABC *abc)\n"
|
checkNullPointer("void freeAbc(struct ABC *abc)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue