Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/vf_analyzers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ struct ValueFlowAnalyzer : Analyzer {
return result;
}
ConditionState lhs = analyzeCondition(tok->astOperand1(), depth - 1);
if (lhs.isUnknownDependent())
if (lhs.isUnknownDependent() || !tok->astOperand2())
return lhs;
ConditionState rhs = analyzeCondition(tok->astOperand2(), depth - 1);
if (rhs.isUnknownDependent())
Expand Down
12 changes: 11 additions & 1 deletion test/testnullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,14 @@ class TestNullPointer : public TestFixture {
" if (h(i) && *i == 1) {}\n"
"}\n");
ASSERT_EQUALS("", errout_str());

check("void f(int i) {\n" // #13797
" int* p = nullptr;\n"
" if (!i) {\n"
" *p = 0;\n"
" }\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4:10]: (error) Null pointer dereference: p [nullPointer]\n", errout_str());
}

void nullpointer78() // #7802
Expand Down Expand Up @@ -3929,7 +3937,9 @@ class TestNullPointer : public TestFixture {
" std::string s(p);\n"
" return s;\n"
"}\n", dinit(CheckOptions, $.inconclusive = true));
ASSERT_EQUALS("", errout_str());
TODO_ASSERT_EQUALS("",
Comment thread
chrchr-github marked this conversation as resolved.
Outdated
"[test.cpp:6:17]: (warning, inconclusive) Possible null pointer dereference: p [nullPointer]\n",
errout_str());

check("void f() {\n" // #11078
" const char* p = nullptr;\n"
Expand Down
Loading