Null pointer: Fixed false positive

This commit is contained in:
Daniel Marjamäki 2010-09-02 21:08:58 +02:00
parent 01b05618e5
commit 190a0040b7
2 changed files with 13 additions and 1 deletions

View File

@ -2431,7 +2431,7 @@ void CheckOther::nullPointerLinkedList()
}
--indentlevel4;
}
else if (tok4->str() == "break")
else if (tok4->str() == "break" || tok4->str() == "return")
break;
}
}

View File

@ -925,6 +925,18 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkNullPointer("void f()\n"
"{\n"
" for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next())\n"
" {\n"
" while (tok && tok->str() != \"{\")\n"
" tok = tok->next();\n"
" if (!tok)\n"
" return;\n"
" }\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// dynamic_cast..
checkNullPointer("void foo(ABC *abc)\n"
"{\n"