fix memory leak during export

pull/2885/head
kimkulling 2020-03-25 16:37:43 +01:00
parent 6f8d96b57e
commit ccd13436da
2 changed files with 94 additions and 88 deletions

View File

@ -292,8 +292,8 @@ void ExportSceneM3D(
// Prototyped and registered in Exporter.cpp
void ExportSceneM3DA(
const char *,
IOSystem*,
const aiScene*,
IOSystem *,
const aiScene *,
const ExportProperties *
) {
@ -312,7 +312,9 @@ void ExportSceneM3DA(
M3DExporter::M3DExporter(const aiScene *pScene, const ExportProperties *pProperties) :
mScene(pScene),
mProperties(pProperties),
outfile() {}
outfile() {
// empty
}
// ------------------------------------------------------------------------------------------------
void M3DExporter::doExport(
@ -352,6 +354,9 @@ void M3DExporter::doExport(
// explicitly release file pointer,
// so we don't have to rely on class destruction.
outfile.reset();
M3D_FREE(m3d->name);
m3d->name = nullptr;
}
// ------------------------------------------------------------------------------------------------

View File

@ -50,15 +50,15 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifdef ASSIMP_USE_M3D_READFILECB
# if (__cplusplus >= 201103L) || !defined(_MSC_VER) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards
# define threadlocal thread_local
# else
# if defined(_MSC_VER) && (_MSC_VER >= 1800) // there's an alternative for MSVC 2013
# define threadlocal __declspec(thread)
# else
# define threadlocal
# endif
# endif
#if (__cplusplus >= 201103L) || !defined(_MSC_VER) || (_MSC_VER >= 1900) // C++11 and MSVC 2015 onwards
#define threadlocal thread_local
#else
#if defined(_MSC_VER) && (_MSC_VER >= 1800) // there's an alternative for MSVC 2013
#define threadlocal __declspec(thread)
#else
#define threadlocal
#endif
#endif
extern "C" {
@ -121,8 +121,9 @@ M3DWrapper::~M3DWrapper() {
void M3DWrapper::reset() {
ClearSave();
if (m3d_)
if (m3d_) {
m3d_free(m3d_);
}
m3d_ = nullptr;
}