From 47fc3f262751c1f15e0912358dedc33abe8cd5ca Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 12 Feb 2020 14:54:00 +0100 Subject: [PATCH] Update M3DImporter.cpp Fix a memoryleak. --- code/M3D/M3DImporter.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/M3D/M3DImporter.cpp b/code/M3D/M3DImporter.cpp index 1c6cea766..9aee14f75 100644 --- a/code/M3D/M3DImporter.cpp +++ b/code/M3D/M3DImporter.cpp @@ -383,7 +383,13 @@ void M3DImporter::importTextures(const M3DWrapper &m3d) { // individually. In assimp there're per mesh vertex and UV lists, and they must be // indexed simultaneously. void M3DImporter::importMeshes(const M3DWrapper &m3d) { - unsigned int i, j, k, l, numpoly = 3, lastMat = M3D_INDEXMAX; + ASSIMP_LOG_DEBUG_F("M3D: importMeshes ", m3d->numface); + + if (!m3d->numface || !m3d->face || !m3d->numvertex || !m3d->vertex) { + return; + } + + unsigned int i, j, k, l, numpoly = 3, lastMat = M3D_INDEXMAX; std::vector *meshes = new std::vector(); std::vector *faces = nullptr; std::vector *vertices = nullptr; @@ -397,11 +403,6 @@ void M3DImporter::importMeshes(const M3DWrapper &m3d) { ai_assert(m3d); ai_assert(mScene->mRootNode != nullptr); - ASSIMP_LOG_DEBUG_F("M3D: importMeshes ", m3d->numface); - - if (!m3d->numface || !m3d->face || !m3d->numvertex || !m3d->vertex) { - return; - } for (i = 0; i < m3d->numface; i++) { // we must switch mesh if material changes