Browse Source

Fix coverity findings: fix possible usage after calling free.

Kim Kulling 9 years ago
parent
commit
238f14f30f
2 changed files with 5 additions and 6 deletions
  1. 3 3
      code/glTFExporter.cpp
  2. 2 3
      code/glTFExporter.h

+ 3 - 3
code/glTFExporter.cpp

@@ -93,11 +93,11 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc
     , mScene(pScene)
     , mProperties(pProperties)
 {
-    std::unique_ptr<Asset> asset(new glTF::Asset(pIOSystem));
-    mAsset = asset.get();
+    std::unique_ptr<Asset> asset();
+    mAsset.reset( new glTF::Asset( pIOSystem ) );
 
     if (isBinary) {
-        asset->SetAsBinary();
+        mAsset->SetAsBinary();
     }
 
     ExportMetadata();

+ 2 - 3
code/glTFExporter.h

@@ -46,13 +46,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include <assimp/types.h>
 #include <assimp/material.h>
+
 #include <sstream>
 #include <vector>
 #include <map>
-
 #include <memory>
 
-
 struct aiScene;
 struct aiNode;
 struct aiMaterial;
@@ -89,7 +88,7 @@ namespace Assimp
 
         std::map<std::string, unsigned int> mTexturesByPath;
 
-        glTF::Asset* mAsset;
+        std::shared_ptr<glTF::Asset> mAsset;
 
         std::vector<unsigned char> mBodyData;