Skip to content

Commit 0b96b9d

Browse files
committed
cppcheck-opensource#6505 ValueFlow: handle 2 related if in valueFlowSubFunction. Regression test. Bug got fixed before
1 parent 4400f2a commit 0b96b9d

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/testnullpointer.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class TestNullPointer : public TestFixture {
9292
TEST_CASE(functioncalllibrary); // use Library to parse function call
9393
TEST_CASE(functioncallDefaultArguments);
9494
TEST_CASE(nullpointer_internal_error); // #5080
95+
TEST_CASE(ticket6505);
9596
}
9697

9798
void check(const char code[], bool inconclusive = false, const char filename[] = "test.cpp") {
@@ -2443,6 +2444,22 @@ class TestNullPointer : public TestFixture {
24432444
"}\n");
24442445
ASSERT_EQUALS("", errout.str());
24452446
}
2447+
2448+
void ticket6505() {
2449+
check("void foo(MythSocket *socket) {\n"
2450+
" bool do_write=false;\n"
2451+
" if (socket) {\n"
2452+
" do_write=something();\n"
2453+
" }\n"
2454+
" if (do_write) {\n"
2455+
" socket->func();\n"
2456+
" }\n"
2457+
"}\n"
2458+
"void bar() {\n"
2459+
" foo(0);\n"
2460+
"}\n", true, "test.c");
2461+
ASSERT_EQUALS("", errout.str());
2462+
}
24462463
};
24472464

24482465
REGISTER_TEST(TestNullPointer)

0 commit comments

Comments
 (0)