Fixed #3038 (False Positive - memory leak)

This commit is contained in:
Daniel Marjamäki 2011-08-25 19:59:44 +02:00
parent 047984ea89
commit 6d9463139d
2 changed files with 3 additions and 0 deletions

View File

@ -848,6 +848,8 @@ const char * CheckMemoryLeakInFunction::call_func(const Token *tok, std::list<co
return ret;
}
}
if (varid > 0 && Token::Match(tok, "[(,] %varid% . %var% [,)]", varid))
return "use";
}
}
return NULL;

View File

@ -487,6 +487,7 @@ private:
ASSERT_EQUALS(";;use;;", getcode("char *s; x = {1,s};", "s"));
ASSERT_EQUALS(";{};;alloc;;use;", getcode("struct Foo { }; Foo *p; p = malloc(10); const Foo *q; q = p;", "p"));
ASSERT_EQUALS(";;alloc;use;", getcode("Fred *fred; p.setFred(fred = new Fred);", "fred"));
ASSERT_EQUALS(";;use;", getcode("struct AB *ab; f(ab->a);", "ab"));
// non-use..
ASSERT_EQUALS(";;", getcode("char *s; s = s + 1;", "s"));