diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index e9b1467bd..bd36a4e37 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -485,6 +485,12 @@ void CheckNullPointer::nullPointerByDeRefAndChec() break; } + if (tok1->str() == ")" && Token::simpleMatch(tok1->link()->previous(), "sizeof (")) + { + tok1 = tok1->link()->previous(); + continue; + } + if (tok1->str() == "break") break; diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 53198703c..0c9e09a1f 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -437,6 +437,15 @@ private: " }\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #2525 - sizeof + check("void f() {\n" + " int *test = NULL;\n" + " int c = sizeof(test[0]);\n" + " if (!test)\n" + " ;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void nullpointer5()