Add TestMemleak::realloc4 that currently fail.

Change TestMemleak::if10, TestMemleak::forwhile8 and TestMemleak::realloc2 as they are currently leaking memory, mark them as TODO.
Comment out TestMemleak::forwhile9 and TestMemleak::forwhile10 as they are wrong (infinite loops).
This commit is contained in:
Nicolas Le Cam 2009-03-28 16:13:06 +01:00
parent 022dbc651e
commit ad7df1cbe0
1 changed files with 22 additions and 8 deletions

View File

@ -96,7 +96,7 @@ private:
TEST_CASE(if7); // Bug 2401436 TEST_CASE(if7); // Bug 2401436
TEST_CASE(if8); // Bug 2458532 TEST_CASE(if8); // Bug 2458532
TEST_CASE(if9); // if (realloc) TEST_CASE(if9); // if (realloc)
TEST_CASE(if10); // else if (realloc) // TODO TEST_CASE(if10); // else if (realloc)
TEST_CASE(if11); TEST_CASE(if11);
TEST_CASE(forwhile1); TEST_CASE(forwhile1);
@ -106,9 +106,9 @@ private:
TEST_CASE(forwhile5); TEST_CASE(forwhile5);
TEST_CASE(forwhile6); TEST_CASE(forwhile6);
TEST_CASE(forwhile7); TEST_CASE(forwhile7);
TEST_CASE(forwhile8); // Bug 2429936 // TODO TEST_CASE(forwhile8); // Bug 2429936
TEST_CASE(forwhile9); //TEST_CASE(forwhile9);
TEST_CASE(forwhile10); //TEST_CASE(forwhile10);
TEST_CASE(dowhile1); TEST_CASE(dowhile1);
@ -163,8 +163,9 @@ private:
TEST_CASE(sizeof1); TEST_CASE(sizeof1);
TEST_CASE(realloc1); TEST_CASE(realloc1);
TEST_CASE(realloc2); // TODO TEST_CASE(realloc2);
TEST_CASE(realloc3); TEST_CASE(realloc3);
// TODO TEST_CASE(realloc4);
TEST_CASE(assign); TEST_CASE(assign);
@ -680,7 +681,7 @@ private:
" ;\n" " ;\n"
" free(buf);\n" " free(buf);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS(std::string("[test.cpp:6]: (error) Memory leak: buf\n"), errout.str());
} }
void if11() void if11()
@ -831,7 +832,7 @@ private:
"\n" "\n"
" return a;\n" " return a;\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS(std::string("[test.cpp:10]: (error) Memory leak: a\n"), errout.str());
} }
@ -1646,7 +1647,7 @@ private:
" free(a);\n" " free(a);\n"
"}\n"); "}\n");
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: a\n"), errout.str());
} }
void realloc3() void realloc3()
@ -1662,6 +1663,19 @@ private:
ASSERT_EQUALS(std::string(""), errout.str()); ASSERT_EQUALS(std::string(""), errout.str());
} }
void realloc4()
{
check("void foo()\n"
"{\n"
" static char *a = 0;\n"
" if ((a = realloc(a, 100)) == NULL)\n"
" return;\n"
" free(a);\n"
"}\n");
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) Memory leak: a\n"), errout.str());
}
void assign() void assign()
{ {