Fixes issues our internal compliance and code quality tool found:
* Adds nullptr checks and asserts to protect certain code paths * Fixes wrong integer type in a printf call * Adds const to const values * Prevents integer overflow with explicit castspull/4055/head
parent
5e86fead8e
commit
51f294c587
|
@ -917,8 +917,10 @@ void FBXConverter::ConvertModel(const Model &model, aiNode *parent, aiNode *root
|
||||||
} else if (line) {
|
} else if (line) {
|
||||||
const std::vector<unsigned int> &indices = ConvertLine(*line, root_node);
|
const std::vector<unsigned int> &indices = ConvertLine(*line, root_node);
|
||||||
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
|
std::copy(indices.begin(), indices.end(), std::back_inserter(meshes));
|
||||||
} else {
|
} else if (geo) {
|
||||||
FBXImporter::LogWarn("ignoring unrecognized geometry: ", geo->Name());
|
FBXImporter::LogWarn("ignoring unrecognized geometry: ", geo->Name());
|
||||||
|
} else {
|
||||||
|
FBXImporter::LogWarn("skipping null geometry");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ inline static std::string MakeAbsolutePath(const char *in) {
|
||||||
free(ret);
|
free(ret);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!ret) {
|
else {
|
||||||
// preserve the input path, maybe someone else is able to fix
|
// preserve the input path, maybe someone else is able to fix
|
||||||
// the path before it is accessed (e.g. our file system filter)
|
// the path before it is accessed (e.g. our file system filter)
|
||||||
ASSIMP_LOG_WARN("Invalid path: ", std::string(in));
|
ASSIMP_LOG_WARN("Invalid path: ", std::string(in));
|
||||||
|
|
|
@ -89,6 +89,9 @@ void ScenePreprocessor::ProcessScene() {
|
||||||
ASSIMP_LOG_DEBUG("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'");
|
ASSIMP_LOG_DEBUG("ScenePreprocessor: Adding default material \'" AI_DEFAULT_MATERIAL_NAME "\'");
|
||||||
|
|
||||||
for (unsigned int i = 0; i < scene->mNumMeshes; ++i) {
|
for (unsigned int i = 0; i < scene->mNumMeshes; ++i) {
|
||||||
|
if (nullptr == scene->mMeshes[i]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
scene->mMeshes[i]->mMaterialIndex = scene->mNumMaterials;
|
scene->mMeshes[i]->mMaterialIndex = scene->mNumMaterials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -555,17 +555,23 @@ uint32_t Assimp::ComputeMaterialHash(const aiMaterial *mat, bool includeMatName
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
void aiMaterial::CopyPropertyList(aiMaterial *pcDest,
|
void aiMaterial::CopyPropertyList(aiMaterial *const pcDest,
|
||||||
const aiMaterial *pcSrc) {
|
const aiMaterial *pcSrc) {
|
||||||
ai_assert(nullptr != pcDest);
|
ai_assert(nullptr != pcDest);
|
||||||
ai_assert(nullptr != pcSrc);
|
ai_assert(nullptr != pcSrc);
|
||||||
|
ai_assert(pcDest->mNumProperties <= pcDest->mNumAllocated);
|
||||||
|
ai_assert(pcSrc->mNumProperties <= pcSrc->mNumAllocated);
|
||||||
|
|
||||||
unsigned int iOldNum = pcDest->mNumProperties;
|
const unsigned int iOldNum = pcDest->mNumProperties;
|
||||||
pcDest->mNumAllocated += pcSrc->mNumAllocated;
|
pcDest->mNumAllocated += pcSrc->mNumAllocated;
|
||||||
pcDest->mNumProperties += pcSrc->mNumProperties;
|
pcDest->mNumProperties += pcSrc->mNumProperties;
|
||||||
|
|
||||||
|
const unsigned int numAllocated = pcDest->mNumAllocated;
|
||||||
aiMaterialProperty **pcOld = pcDest->mProperties;
|
aiMaterialProperty **pcOld = pcDest->mProperties;
|
||||||
pcDest->mProperties = new aiMaterialProperty *[pcDest->mNumAllocated];
|
pcDest->mProperties = new aiMaterialProperty *[numAllocated];
|
||||||
|
|
||||||
|
ai_assert(!iOldNum || pcOld);
|
||||||
|
ai_assert(iOldNum < numAllocated);
|
||||||
|
|
||||||
if (iOldNum && pcOld) {
|
if (iOldNum && pcOld) {
|
||||||
for (unsigned int i = 0; i < iOldNum; ++i) {
|
for (unsigned int i = 0; i < iOldNum; ++i) {
|
||||||
|
|
|
@ -170,7 +170,7 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode *nd, std::list<aiNode *> &n
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
if (join_master && !join.empty()) {
|
if (join_master && !join.empty()) {
|
||||||
join_master->mName.length = ::ai_snprintf(join_master->mName.data, MAXLEN, "$MergedNode_%i", count_merged++);
|
join_master->mName.length = ::ai_snprintf(join_master->mName.data, MAXLEN, "$MergedNode_%u", count_merged++);
|
||||||
|
|
||||||
unsigned int out_meshes = 0;
|
unsigned int out_meshes = 0;
|
||||||
for (std::list<aiNode *>::const_iterator it = join.cbegin(); it != join.cend(); ++it) {
|
for (std::list<aiNode *>::const_iterator it = join.cbegin(); it != join.cend(); ++it) {
|
||||||
|
|
|
@ -481,7 +481,7 @@ void PretransformVertices::Execute(aiScene *pScene) {
|
||||||
pScene->mMeshes[i]->mNumBones = 0;
|
pScene->mMeshes[i]->mNumBones = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
apcOutMeshes.reserve(pScene->mNumMaterials << 1u);
|
apcOutMeshes.reserve(static_cast<size_t>(pScene->mNumMaterials) << 1u);
|
||||||
std::list<unsigned int> aiVFormats;
|
std::list<unsigned int> aiVFormats;
|
||||||
|
|
||||||
std::vector<unsigned int> s(pScene->mNumMeshes, 0);
|
std::vector<unsigned int> s(pScene->mNumMeshes, 0);
|
||||||
|
|
|
@ -127,7 +127,7 @@ void SortByPTypeProcess::Execute(aiScene *pScene) {
|
||||||
unsigned int aiNumMeshesPerPType[4] = { 0, 0, 0, 0 };
|
unsigned int aiNumMeshesPerPType[4] = { 0, 0, 0, 0 };
|
||||||
|
|
||||||
std::vector<aiMesh *> outMeshes;
|
std::vector<aiMesh *> outMeshes;
|
||||||
outMeshes.reserve(pScene->mNumMeshes << 1u);
|
outMeshes.reserve(static_cast<size_t>(pScene->mNumMeshes) << 1u);
|
||||||
|
|
||||||
bool bAnyChanges = false;
|
bool bAnyChanges = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue