diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 80b451a7055..80ea644c781 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -6941,7 +6941,7 @@ static void valueFlowFunctionDefaultParameter(const TokenList& tokenlist, const continue; for (std::size_t arg = function->minArgCount(); arg < function->argCount(); arg++) { const Variable* var = function->getArgumentVar(arg); - if (var && var->hasDefault() && Token::Match(var->nameToken(), "%var% = %num%|%str% [,)]")) { + if (var && var->hasDefault() && Token::Match(var->nameToken(), "%var% = %num%|%str%|%char%|%name% [,)]")) { const std::list &values = var->nameToken()->tokAt(2)->values(); std::list argvalues; for (const ValueFlow::Value &value : values) { diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index a9a2a82043d..6a026119d30 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -4405,6 +4405,10 @@ class TestNullPointer : public TestFixture { " int var1 = x ? *p : 5;\n" "}"); ASSERT_EQUALS("[test.cpp:2]: (warning) Possible null pointer dereference if the default parameter value is used: p\n", errout_str()); + + check("void f(int* i = nullptr) { *i = 0; }\n" // #11567 + "void g() { f(); }\n"); + ASSERT_EQUALS("[test.cpp:1]: (warning) Possible null pointer dereference if the default parameter value is used: i\n", errout_str()); } void nullpointer_internal_error() { // ticket #5080