]> git.mxchange.org Git - flightgear.git/blobdiff - src/Model/modelmgr.cxx
Not reported by cppcheck: fix another memory leak :)
[flightgear.git] / src / Model / modelmgr.cxx
index 600086d29e9d77ece1819bc319f6e8f6fac1fa87..2e6ad72bcdaf19b498301a6f7503859cd14c1d7f 100644 (file)
@@ -16,6 +16,7 @@
 #include <algorithm>
 #include <functional>
 #include <vector>
+#include <cstring>
 
 #include <osg/Math>
 
@@ -69,10 +70,6 @@ FGModelMgr::add_model (SGPropertyNode * node)
 {
   SG_LOG(SG_GENERAL, SG_INFO,
          "Adding model " << node->getStringValue("name", "[unnamed]"));
-  Instance * instance = new Instance;
-  SGModelPlacement *model = new SGModelPlacement;
-  instance->model = model;
-  instance->node = node;
 
   const char *path = node->getStringValue("path", "Models/Geometry/glider.ac");
   osg::Node *object;
@@ -84,6 +81,11 @@ FGModelMgr::add_model (SGPropertyNode * node)
         << t.getFormattedMessage() << t.getOrigin());
     return;
   }
+  
+  Instance * instance = new Instance;
+  SGModelPlacement *model = new SGModelPlacement;
+  instance->model = model;
+  instance->node = node;
 
   model->init( object );