]> git.mxchange.org Git - flightgear.git/commitdiff
Fix for a premature deletion bug. The _arg SGPropertyNode* is passed
authorandy <andy>
Mon, 22 Dec 2003 19:18:22 +0000 (19:18 +0000)
committerandy <andy>
Mon, 22 Dec 2003 19:18:22 +0000 (19:18 +0000)
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.

src/Input/input.cxx
src/Input/input.hxx

index 54cecb9c2a07a624da0500d7ca0c1de5e5e48347..5d2f207d8347eaa2b1f93d039b13c0ceee5f2baf 100644 (file)
@@ -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!!!
index c3f980f0d1d5a44a3783d931e930b87e3c53d14f..9e043a7bba9fb4ad145af092539deed87ee9729e 100644 (file)
@@ -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;
 };