Skip to content
Open
Show file tree
Hide file tree
Changes from all 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/checkunusedfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ bool CheckUnusedFunctions::check(const Settings& settings, ErrorLogger& errorLog
if (func.filename != "+")
filename = func.filename;
errors.emplace_back(filename, func.fileIndex, func.lineNumber, func.column, it->first);
} else if (func.isC && !func.isStatic && !func.usedOtherFile) {
} else if (func.isC && !func.isStatic) {
std::string filename;
if (func.filename != "+")
filename = func.filename;
Expand Down
2 changes: 1 addition & 1 deletion lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ Library::Error Library::load(const char exename[], const char path[], bool debug
tinyxml2::XMLError error = xml_LoadFile(doc, fullfilename.c_str());
if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND) {
// only perform further lookups when the given path was not absolute
if (!is_abs_path && error == tinyxml2::XML_ERROR_FILE_NOT_FOUND)
if (!is_abs_path)
{
std::list<std::string> cfgfolders;
#ifdef FILESDIR
Expand Down
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ void SymbolDatabase::createSymbolDatabaseNeedInitialization()
if (var.isClass() && !var.isReference()) {
if (var.type()) {
// does this type need initialization?
if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault() && !var.isStatic())
if (var.type()->needInitialization == Type::NeedInitialization::True && !var.hasDefault())
needInitialization = true;
else if (var.type()->needInitialization == Type::NeedInitialization::Unknown) {
if (!(var.valueType() && var.valueType()->type == ValueType::CONTAINER))
Expand Down
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -1202,7 +1202,7 @@ struct SingleValueFlowAnalyzer : ValueFlowAnalyzer {
return false;
if (value.isImpossible())
return false;
if (isConditional() && !value.isKnown() && !value.isImpossible())
if (isConditional() && !value.isKnown())
return true;
if (value.isSymbolicValue())
return false;
Expand Down
11 changes: 10 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,8 @@ class TestNullPointer : public TestFixture {
" std::string s(p);\n"
" return s;\n"
"}\n", dinit(CheckOptions, $.inconclusive = true));
ASSERT_EQUALS("", errout_str());
ASSERT_EQUALS("[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