From: andy Date: Mon, 22 Dec 2003 19:18:22 +0000 (+0000) Subject: Fix for a premature deletion bug. The _arg SGPropertyNode* is passed X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d14bba8458d6b1276b33467610d3dbc5a3f8d939;p=flightgear.git 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. --- diff --git a/src/Input/input.cxx b/src/Input/input.cxx index 54cecb9c2..5d2f207d8 100644 --- a/src/Input/input.cxx +++ b/src/Input/input.cxx @@ -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!!! diff --git a/src/Input/input.hxx b/src/Input/input.hxx index c3f980f0d..9e043a7bb 100644 --- a/src/Input/input.hxx +++ b/src/Input/input.hxx @@ -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; };