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;
|
||||
}
|
||||
|
||||
// goto destination..
|
||||
else if (tok2->isName() && Token::simpleMatch(tok2->next(), ":"))
|
||||
break;
|
||||
|
||||
// Reassignment of the struct
|
||||
else if (tok2->varId() == varid1)
|
||||
{
|
||||
|
@ -1194,6 +1198,10 @@ void CheckOther::nullPointer()
|
|||
else if (tok1->str() == "{" ||
|
||||
tok1->str() == "}")
|
||||
break;
|
||||
|
||||
// goto destination..
|
||||
else if (tok1->isName() && Token::simpleMatch(tok1->next(), ":"))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -532,6 +532,15 @@ private:
|
|||
"}\n");
|
||||
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..
|
||||
checkNullPointer("void freeAbc(struct ABC *abc)\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue