From 238f14f30fb2bb7ad2d413dac86be878d5f51103 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 29 Aug 2016 15:28:37 +0200 Subject: [PATCH] Fix coverity findings: fix possible usage after calling free. --- code/glTFExporter.cpp | 6 +++--- code/glTFExporter.h | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/code/glTFExporter.cpp b/code/glTFExporter.cpp index 7f0c086cf..3b9c1b67b 100644 --- a/code/glTFExporter.cpp +++ b/code/glTFExporter.cpp @@ -93,11 +93,11 @@ glTFExporter::glTFExporter(const char* filename, IOSystem* pIOSystem, const aiSc , mScene(pScene) , mProperties(pProperties) { - std::unique_ptr asset(new glTF::Asset(pIOSystem)); - mAsset = asset.get(); + std::unique_ptr asset(); + mAsset.reset( new glTF::Asset( pIOSystem ) ); if (isBinary) { - asset->SetAsBinary(); + mAsset->SetAsBinary(); } ExportMetadata(); diff --git a/code/glTFExporter.h b/code/glTFExporter.h index 884d1fe38..dfd0108b5 100644 --- a/code/glTFExporter.h +++ b/code/glTFExporter.h @@ -46,13 +46,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include + #include #include #include - #include - struct aiScene; struct aiNode; struct aiMaterial; @@ -89,7 +88,7 @@ namespace Assimp std::map mTexturesByPath; - glTF::Asset* mAsset; + std::shared_ptr mAsset; std::vector mBodyData;