Merge pull request #4226 from umlaeute/bugfix/import-crashes

Bugfix/import crashes
pull/4260/head
Kim Kulling 2021-12-16 14:51:34 +01:00 committed by GitHub
commit 46b28a442b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -393,7 +393,7 @@ void LWOImporter::InternReadFile(const std::string &pFile,
// If a RGB color map is explicitly requested delete the // If a RGB color map is explicitly requested delete the
// alpha channel - it could theoretically be != 1. // alpha channel - it could theoretically be != 1.
if (_mSurfaces[i].mVCMapType == AI_LWO_RGB) if (_mSurfaces[j].mVCMapType == AI_LWO_RGB)
pvVC[w]->a = 1.f; pvVC[w]->a = 1.f;
pvVC[w]++; pvVC[w]++;

View File

@ -50,6 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/ParsingUtils.h> #include <assimp/ParsingUtils.h>
#include "ProcessHelper.h" #include "ProcessHelper.h"
#include "Material/MaterialSystem.h" #include "Material/MaterialSystem.h"
#include <assimp/Exceptional.h>
#include <stdio.h> #include <stdio.h>
using namespace Assimp; using namespace Assimp;
@ -171,6 +172,8 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene)
} }
// If the new material count differs from the original, // If the new material count differs from the original,
// we need to rebuild the material list and remap mesh material indexes. // we need to rebuild the material list and remap mesh material indexes.
if(iNewNum < 1)
throw DeadlyImportError("No materials remaining");
if (iNewNum != pScene->mNumMaterials) { if (iNewNum != pScene->mNumMaterials) {
ai_assert(iNewNum > 0); ai_assert(iNewNum > 0);
aiMaterial** ppcMaterials = new aiMaterial*[iNewNum]; aiMaterial** ppcMaterials = new aiMaterial*[iNewNum];