Fixed #1923 (False positive: Possible null pointer derefence in else if)
This commit is contained in:
parent
262885f3e0
commit
029613d4c4
|
@ -2394,7 +2394,7 @@ void CheckOther::nullPointerStructByDeRefAndChec()
|
||||||
|
|
||||||
else if (tok2->str() == "}")
|
else if (tok2->str() == "}")
|
||||||
{
|
{
|
||||||
if (indentlevel2 == 0)
|
if (indentlevel2 <= 1)
|
||||||
break;
|
break;
|
||||||
--indentlevel2;
|
--indentlevel2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -781,6 +781,18 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// ticket #1923 - no false positive when using else if
|
||||||
|
checkNullPointer("void f(A *a)\n"
|
||||||
|
"{\n"
|
||||||
|
" if (a->x == 1)\n"
|
||||||
|
" {\n"
|
||||||
|
" a = a->next;\n"
|
||||||
|
" }\n"
|
||||||
|
" else if (a->x == 2) { }\n"
|
||||||
|
" if (a) { }\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nullpointer2()
|
void nullpointer2()
|
||||||
|
|
Loading…
Reference in New Issue