Fix: Fix leak when sortbyp failes with exception (#6166)

Co-authored-by: Kim Kulling <kim.kulling@draeger.com>
This commit is contained in:
Kim Kulling
2025-05-14 11:43:12 +02:00
committed by GitHub
co-authored by Kim Kulling
parent 64073458bd
commit 9d9a80739d
4 changed files with 14 additions and 3 deletions
+4 -3
View File
@@ -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());
}