Skip to content

Commit 8e12016

Browse files
Update testnullpointer.cpp
1 parent dfab1be commit 8e12016

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

test/testnullpointer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3392,6 +3392,20 @@ class TestNullPointer : public TestFixture {
33923392
" pointer = func(sizeof pointer[0]);\n"
33933393
"}");
33943394
ASSERT_EQUALS("", errout_str());
3395+
3396+
check("struct T {\n" // #14164
3397+
" T* next;\n"
3398+
" char op;\n"
3399+
"};\n"
3400+
"void h(int, char);\n"
3401+
"void g(const T* tok, bool b) {\n"
3402+
" if (tok->op == '<') {\n"
3403+
" while ((tok = tok->next) && tok->op != '>') {}\n"
3404+
" }\n"
3405+
" h(b ? 1 : 0, tok->op);\n"
3406+
"}\n");
3407+
ASSERT_EQUALS("[test.cpp:8:21] -> [test.cpp:10:18]: (warning) Either the condition 'tok=tok->next' is redundant or there is possible null pointer dereference: tok. [nullPointerRedundantCheck]\n",
3408+
errout_str());
33953409
}
33963410

33973411
// Test CheckNullPointer::nullConstantDereference

0 commit comments

Comments
 (0)