Use unique_ptr to avoid memory leak in 3d model cache loading
PVS V773
This commit is contained in:
parent
3af606a020
commit
f5a56c1ebc
|
@ -25,6 +25,7 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <wx/filename.h>
|
||||
#include <wx/log.h>
|
||||
#include "plugins/3dapi/ifsg_api.h"
|
||||
|
@ -233,14 +234,12 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
SGNODE* np = new SCENEGRAPH( nullptr );
|
||||
std::unique_ptr<SGNODE> np = std::make_unique<SCENEGRAPH>( nullptr );
|
||||
|
||||
OPEN_ISTREAM( file, aFileName );
|
||||
|
||||
if( file.fail() )
|
||||
{
|
||||
delete np;
|
||||
|
||||
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] failed to open file '%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__, aFileName );
|
||||
|
||||
|
@ -324,8 +323,6 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr,
|
|||
|
||||
if( !rval )
|
||||
{
|
||||
delete np;
|
||||
|
||||
wxLogTrace( MASK_3D_SG, wxT( "%s:%s:%d * [INFO] problems encountered reading cache file "
|
||||
"'%s'" ),
|
||||
__FILE__, __FUNCTION__, __LINE__,
|
||||
|
@ -334,7 +331,7 @@ SGNODE* S3D::ReadCache( const char* aFileName, void* aPluginMgr,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
return np;
|
||||
return np.release();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue