diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 32dedf8f374..7d60410f9ca 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3557,7 +3557,7 @@ void CheckOther::checkVarFuncNullUB() for (const Scope * scope : symbolDatabase->functionScopes) { for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) { // Is NULL passed to a function? - if (Token::Match(tok,"[(,] NULL [,)]")) { + if (Token::Match(tok,"[(,] NULL )")) { // Locate function name in this function call. const Token *ftok = tok; int argnr = 1; diff --git a/test/testother.cpp b/test/testother.cpp index 53f14c2a31d..e502dcc5ff9 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -11295,6 +11295,12 @@ class TestOther : public TestFixture { check("void a(char *p, ...);\n" "void b() { a(NULL, 2); }"); ASSERT_EQUALS("", errout_str()); + + checkP("extern const int sentinel;\n" + "void a(int, ...);\n" + "#define b(x, ...) a((x), __VA_ARGS__, &sentinel)\n" + "void c() { b(1, NULL); }"); + ASSERT_EQUALS("", errout_str()); } void checkCastIntToCharAndBack() { // #160