Fix for a premature deletion bug. The _arg SGPropertyNode* is passed
to handlers which might want to assign it to a SGPropertyNode_ptr for reference counting (Nasal does, for instance, to prevent garbage collector interactions). If that smart pointer is then destroyed, that will free this object while it is still live. Simply use a SGPropertyNode_ptr here; the code ends up smaller as a bonus, since FGBinding no longer has to deallocation for _arg.
This commit is contained in:
parent
a59a272702
commit
d14bba8458
2 changed files with 2 additions and 8 deletions
|
@ -94,11 +94,6 @@ FGBinding::FGBinding (const SGPropertyNode * node)
|
|||
read(node);
|
||||
}
|
||||
|
||||
FGBinding::~FGBinding ()
|
||||
{
|
||||
delete _arg; // Delete the saved arguments
|
||||
}
|
||||
|
||||
void
|
||||
FGBinding::read (const SGPropertyNode * node)
|
||||
{
|
||||
|
@ -113,7 +108,6 @@ FGBinding::read (const SGPropertyNode * node)
|
|||
return;
|
||||
}
|
||||
|
||||
delete _arg;
|
||||
_arg = new SGPropertyNode;
|
||||
_setting = 0;
|
||||
copyProperties(node, _arg); // FIXME: don't use whole node!!!
|
||||
|
|
|
@ -83,7 +83,7 @@ public:
|
|||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~FGBinding ();
|
||||
virtual ~FGBinding () {}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
|
||||
string _command_name;
|
||||
mutable SGCommandMgr::command_t _command;
|
||||
mutable SGPropertyNode * _arg;
|
||||
mutable SGPropertyNode_ptr _arg;
|
||||
mutable SGPropertyNode_ptr _setting;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue