Fixed #1923 (False positive: Possible null pointer derefence in else if)

This commit is contained in:
Daniel Marjamäki 2010-08-07 19:59:56 +02:00
parent 262885f3e0
commit 029613d4c4
2 changed files with 13 additions and 1 deletions

View File

@ -2394,7 +2394,7 @@ void CheckOther::nullPointerStructByDeRefAndChec()
else if (tok2->str() == "}")
{
if (indentlevel2 == 0)
if (indentlevel2 <= 1)
break;
--indentlevel2;
}

View File

@ -781,6 +781,18 @@ private:
" }\n"
"}\n");
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()