From 0b96b9d9842e5e438f22a9443680d40279e4ad2e Mon Sep 17 00:00:00 2001 From: Alexander Mai Date: Fri, 31 Jul 2015 21:15:43 +0200 Subject: [PATCH] #6505 ValueFlow: handle 2 related if in valueFlowSubFunction. Regression test. Bug got fixed before --- test/testnullpointer.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index e2ed18678..5ae453f50 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -92,6 +92,7 @@ private: TEST_CASE(functioncalllibrary); // use Library to parse function call TEST_CASE(functioncallDefaultArguments); TEST_CASE(nullpointer_internal_error); // #5080 + TEST_CASE(ticket6505); } void check(const char code[], bool inconclusive = false, const char filename[] = "test.cpp") { @@ -2443,6 +2444,22 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); } + + void ticket6505() { + check("void foo(MythSocket *socket) {\n" + " bool do_write=false;\n" + " if (socket) {\n" + " do_write=something();\n" + " }\n" + " if (do_write) {\n" + " socket->func();\n" + " }\n" + "}\n" + "void bar() {\n" + " foo(0);\n" + "}\n", true, "test.c"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestNullPointer)