* Added test case from #8302 and a TODO * Check with in C++ mode to get rid of TODO. * Updated expected error message text * Updated expected error message text
This commit is contained in:
parent
a62fedc641
commit
6ea88c2758
|
@ -112,6 +112,7 @@ private:
|
||||||
TEST_CASE(deallocuse8); // #1765
|
TEST_CASE(deallocuse8); // #1765
|
||||||
TEST_CASE(deallocuse9); // #9781
|
TEST_CASE(deallocuse9); // #9781
|
||||||
TEST_CASE(deallocuse10);
|
TEST_CASE(deallocuse10);
|
||||||
|
TEST_CASE(deallocuse11); // #8302
|
||||||
|
|
||||||
TEST_CASE(doublefree1);
|
TEST_CASE(doublefree1);
|
||||||
TEST_CASE(doublefree2);
|
TEST_CASE(doublefree2);
|
||||||
|
@ -840,6 +841,22 @@ private:
|
||||||
ASSERT_EQUALS("[test.c:2] -> [test.c:3]: (error) Returning/dereferencing 'p' after it is deallocated / released\n", errout.str());
|
ASSERT_EQUALS("[test.c:2] -> [test.c:3]: (error) Returning/dereferencing 'p' after it is deallocated / released\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void deallocuse11() { // #8302
|
||||||
|
check("int f() {\n"
|
||||||
|
" int *array = new int[42];\n"
|
||||||
|
" delete [] array;\n"
|
||||||
|
" return array[1];" // <<
|
||||||
|
"}", true);
|
||||||
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Returning/dereferencing 'array' after it is deallocated / released\n", errout.str());
|
||||||
|
|
||||||
|
check("int f() {\n"
|
||||||
|
" int *array = (int*)malloc(40);\n"
|
||||||
|
" free(array);\n"
|
||||||
|
" return array[1];" // <<
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.c:3] -> [test.c:4]: (error) Returning/dereferencing 'array' after it is deallocated / released\n", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void doublefree1() { // #3895
|
void doublefree1() { // #3895
|
||||||
check("void f(char *p) {\n"
|
check("void f(char *p) {\n"
|
||||||
" if (x)\n"
|
" if (x)\n"
|
||||||
|
|
Loading…
Reference in New Issue