Fixed #1949: assert() hides memory leaks
Added separate unit-test (trac1949), initially broken to highlight the error and added "assert" to call_func_white_list. Left TestMemleakInFunction::call_func() as is, as this wouldn't highlight the actual problem.
This commit is contained in:
parent
cdecbe29d0
commit
6a52538a9a
|
@ -44,7 +44,7 @@ CheckMemoryLeakStructMember instance3;
|
||||||
// This list needs to be alphabetically sorted so we can run bsearch on it
|
// This list needs to be alphabetically sorted so we can run bsearch on it
|
||||||
static const char * const call_func_white_list[] =
|
static const char * const call_func_white_list[] =
|
||||||
{
|
{
|
||||||
"asctime", "asctime_r", "asprintf", "atof", "atoi", "atol", "clearerr"
|
"asctime", "asctime_r", "asprintf", "assert", "atof", "atoi", "atol", "clearerr"
|
||||||
, "ctime", "ctime_r", "delete", "fchmod", "fclose", "fcntl"
|
, "ctime", "ctime_r", "delete", "fchmod", "fclose", "fcntl"
|
||||||
, "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets"
|
, "fdatasync", "feof", "ferror", "fflush", "fgetc", "fgetpos", "fgets"
|
||||||
, "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "fscanf", "fseek"
|
, "flock", "for", "fprintf", "fputc", "fputs", "fread", "free", "fscanf", "fseek"
|
||||||
|
|
|
@ -408,6 +408,8 @@ private:
|
||||||
|
|
||||||
// setjmp/longjmp..
|
// setjmp/longjmp..
|
||||||
TEST_CASE(jmp);
|
TEST_CASE(jmp);
|
||||||
|
|
||||||
|
TEST_CASE(trac1949);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2985,6 +2987,23 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void trac1949()
|
||||||
|
{
|
||||||
|
check("\n"
|
||||||
|
"\n"
|
||||||
|
"int fn()\n"
|
||||||
|
"{\n"
|
||||||
|
"char * buff = new char[100];\n"
|
||||||
|
"assert (buff);\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"\n"
|
||||||
|
"return 0;\n"
|
||||||
|
"}\n"
|
||||||
|
);
|
||||||
|
ASSERT_EQUALS("[test.cpp:10]: (error) Memory leak: buff\n", errout.str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static TestMemleakInFunction testMemleakInFunction;
|
static TestMemleakInFunction testMemleakInFunction;
|
||||||
|
|
Loading…
Reference in New Issue