Fix: Fix leak when sortbyp failes with exception (#6166)
Co-authored-by: Kim Kulling <kim.kulling@draeger.com>
This commit is contained in:
@@ -354,9 +354,10 @@ ASSIMP_API const aiScene *aiApplyCustomizedPostProcessing(const aiScene *scene,
|
||||
void CallbackToLogRedirector(const char *msg, char *dt) {
|
||||
ai_assert(nullptr != msg);
|
||||
ai_assert(nullptr != dt);
|
||||
LogStream *s = (LogStream *)dt;
|
||||
|
||||
s->write(msg);
|
||||
LogStream *stream = (LogStream *)dt;
|
||||
if (stream != nullptr) {
|
||||
stream->write(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static LogStream *DefaultStream = nullptr;
|
||||
|
||||
@@ -136,6 +136,9 @@ void SortByPTypeProcess::Execute(aiScene *pScene) {
|
||||
for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
||||
aiMesh *const mesh = pScene->mMeshes[i];
|
||||
if (mesh->mPrimitiveTypes == 0) {
|
||||
for (size_t idx = 0; idx < outMeshes.size(); ++idx) {
|
||||
delete outMeshes[idx];
|
||||
}
|
||||
throw DeadlyImportError("Mesh with invalid primitive type: ", mesh->mName.C_Str());
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -43,6 +43,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "Common/ScenePreprocessor.h"
|
||||
#include "PostProcessing/SortByPTypeProcess.h"
|
||||
#include <assimp/scene.h>
|
||||
#include <assimp/postprocess.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace Assimp;
|
||||
@@ -202,3 +203,9 @@ TEST_F(SortByPTypeProcessTest, SortByPTypeStep) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(SortByPTypeProcessTest, issue389327770Test) {
|
||||
Assimp::Importer importer;
|
||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/fuzzer_data/clusterfuzz-testcase-minimized-assimp_fuzzer-4751812606885888", aiProcessPreset_TargetRealtime_Fast);
|
||||
EXPECT_NE(nullptr, scene);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user