cmVariableWatch: Fix potential memory leak
Teach cmVariableWatch::AddWatch to own the Pair it allocates until it needs to pass ownership to WatchMap.
This commit is contained in:
parent
6052e4b3bf
commit
75e3e0d3dc
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include "cmAlgorithms.h"
|
#include "cmAlgorithms.h"
|
||||||
|
|
||||||
|
#include <cmsys/auto_ptr.hxx>
|
||||||
|
|
||||||
static const char* const cmVariableWatchAccessStrings[] = {
|
static const char* const cmVariableWatchAccessStrings[] = {
|
||||||
"READ_ACCESS", "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
|
"READ_ACCESS", "UNKNOWN_READ_ACCESS", "UNKNOWN_DEFINED_ACCESS",
|
||||||
"MODIFIED_ACCESS", "REMOVED_ACCESS", "NO_ACCESS"
|
"MODIFIED_ACCESS", "REMOVED_ACCESS", "NO_ACCESS"
|
||||||
@ -46,7 +48,7 @@ bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
|
|||||||
void* client_data /*=0*/,
|
void* client_data /*=0*/,
|
||||||
DeleteData delete_data /*=0*/)
|
DeleteData delete_data /*=0*/)
|
||||||
{
|
{
|
||||||
cmVariableWatch::Pair* p = new cmVariableWatch::Pair;
|
cmsys::auto_ptr<cmVariableWatch::Pair> p(new cmVariableWatch::Pair);
|
||||||
p->Method = method;
|
p->Method = method;
|
||||||
p->ClientData = client_data;
|
p->ClientData = client_data;
|
||||||
p->DeleteDataCall = delete_data;
|
p->DeleteDataCall = delete_data;
|
||||||
@ -60,7 +62,7 @@ bool cmVariableWatch::AddWatch(const std::string& variable, WatchMethod method,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vp->push_back(p);
|
vp->push_back(p.release());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user