Skip to content

Commit bd92363

Browse files
committed
Only consider last NULL argument in varFuncNullUB
Resolving a FP in which the expanded macro ensures that the last variadic argument is not NULL.
1 parent da110ba commit bd92363

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,7 @@ void CheckOther::checkVarFuncNullUB()
35573557
for (const Scope * scope : symbolDatabase->functionScopes) {
35583558
for (const Token* tok = scope->bodyStart; tok != scope->bodyEnd; tok = tok->next()) {
35593559
// Is NULL passed to a function?
3560-
if (Token::Match(tok,"[(,] NULL [,)]")) {
3560+
if (Token::Match(tok,"[(,] NULL )")) {
35613561
// Locate function name in this function call.
35623562
const Token *ftok = tok;
35633563
int argnr = 1;

test/testother.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11295,6 +11295,12 @@ class TestOther : public TestFixture {
1129511295
check("void a(char *p, ...);\n"
1129611296
"void b() { a(NULL, 2); }");
1129711297
ASSERT_EQUALS("", errout_str());
11298+
11299+
checkP("extern const int sentinel;\n"
11300+
"void a(int, ...);\n"
11301+
"#define b(x, ...) a((x), __VA_ARGS__, &sentinel)\n"
11302+
"void c() { b(1, NULL); }");
11303+
ASSERT_EQUALS("", errout_str());
1129811304
}
1129911305

1130011306
void checkCastIntToCharAndBack() { // #160

0 commit comments

Comments
 (0)