Tests: Added "testmemcheck4", memory leak from a strdup

This commit is contained in:
Daniel Marjamäki 2007-05-19 17:26:28 +00:00
parent c3efd64b27
commit 9523f0e2e8
3 changed files with 15 additions and 2 deletions

View File

@ -699,7 +699,7 @@ void CreateStatementList()
if ( ismalloc )
AppendStatement(STATEMENT::MALLOC, tok2, varname);
if ( match(rs,"new type ;") )
else if ( match(rs,"new type ;") )
AppendStatement(STATEMENT::NEW, tok2, varname);
else if ( match(rs, "new type (") )
@ -1128,7 +1128,7 @@ void CheckMemoryLeak()
if (varlist[i]->indentlevel != indentlevel)
continue;
if (varlist[i]->value == _variable::New || varlist[i]->value == _variable::NewA)
if (varlist[i]->value == _variable::Malloc || varlist[i]->value == _variable::New || varlist[i]->value == _variable::NewA)
{
std::ostringstream ostr;
ostr << FileLine(it->Token) << ": Memory leak:" << VariableNames[varlist[i]->varindex];

1
testmemcheck4/out.err Normal file
View File

@ -0,0 +1 @@
[testmemcheck4\testmemcheck4.cpp:10]: Memory leak:str

View File

@ -0,0 +1,12 @@
void f()
{
for (int i = 0; i < j; i++)
{
char *str = strdup("hello");
if (condition)
continue;
}
}