forked from KindDragon/vld
-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Ideally VLD should detect this leak:
#include <stdlib.h>
static void* v = malloc(1); // allocation of raw pointer, no automatic free
int main()
{
// do something with v
return 0;
}But should not detect this:
#include <string>
static std::string s("my string"); // allocates string but destructor will be called at exit
int main()
{
// something using s
return 0;
}The current solution will not detect either of those cases as leaks.
We could do better by seeing static initializations with constructors in the stack and assuming that destructors will be called. That is slightly more complex than the existing logic, but could be done without too much difficulty. Then we could still consider the code above a leak, that could be "fixed" with an explicit free call.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request