Added regression test cases for #404.

This commit is contained in:
PKEuS 2012-08-26 11:39:17 +02:00
parent 4b1075b34b
commit 1fbaae948c
2 changed files with 20 additions and 0 deletions

View File

@ -94,6 +94,8 @@ private:
TEST_CASE(configuration2);
TEST_CASE(configuration3);
TEST_CASE(configuration4);
TEST_CASE(ptrptr);
}
void check(const char code[]) {
@ -545,6 +547,13 @@ private:
"}");
ASSERT_EQUALS("[test.c:4]: (information) set_data configuration is needed to establish if there is a leak or not\n", errout.str());
}
void ptrptr() {
check("void f() {\n"
" char **p = malloc(10);\n"
"}");
ASSERT_EQUALS("[test.c:3]: (error) Memory leak: p\n", errout.str());
}
};
REGISTER_TEST(TestLeakAutoVar)

View File

@ -353,6 +353,8 @@ private:
TEST_CASE(trac1879);
TEST_CASE(garbageCode);
TEST_CASE(ptrptr);
}
@ -3800,6 +3802,15 @@ private:
"}");
}
void ptrptr() {
check("void f() {\n"
" char *p;\n"
" char **pp = &p;\n"
" *pp = calloc(10);\n"
"}");
ASSERT_EQUALS("[test.cpp:5]: (error) Memory leak: p\n", errout.str());
}
};
static TestMemleakInFunction testMemleakInFunction;