From 8d07e3433665f0a30ab4756d538052ff2955a5f1 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 29 Dec 2015 20:46:41 +0100 Subject: [PATCH 1/8] travis config: remove coverity config from master branch. --- .travis.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 18fde43bc..66b53f686 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,6 @@ branches: env: global: - PV=r8e PLATF=linux-x86_64 NDK_HOME=${TRAVIS_BUILD_DIR}/android-ndk-${PV} PATH=${PATH}:${NDK_HOME} - - secure: "lZ7pHQvl5dpZWzBQAaIMf0wqrvtcZ4wiZKeIZjf83TEsflW8+z0uTpIuN30ZV6Glth/Sq1OhLnTP5+N57fZU/1ebA5twHdvP4bS5CIUUg71/CXQZNl36xeaqvxsG/xRrdpKOsPdjAOsQ9KPTQulsX43XDLS7CasMiLvYOpqKcPc=" matrix: - LINUX=1 TRAVIS_NO_EXPORT=YES - LINUX=1 TRAVIS_NO_EXPORT=NO @@ -30,14 +29,3 @@ install: script: - . ./.travis.sh - -addons: - coverity_scan: - project: - name: "assimp/assimp" - version: 3.2 - description: "The Asset Importer Lib coverity run" - notification_email: kim.kulling@googlemail.com - build_command_prepend: cmake -G "Unix Makefiles" -DASSIMP_ENABLE_BOOST_WORKAROUND=YES -DASSIMP_NO_EXPORT=$TRAVIS_NO_EXPORT -DBUILD_SHARED_LIBS=$SHARED_BUILD - build_command: make - branch_pattern: coverity_scan From 0c1b5355f4a0210a6f1162f1302a7b69969ee4f6 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 15:35:26 +0100 Subject: [PATCH 2/8] Coverity finding: remove not used function. --- code/OpenGEXImporter.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index ab702b717..f260cc772 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -801,19 +801,6 @@ void OpenGEXImporter::handleColorNode( ODDLParser::DDLNode *node, aiScene *pScen } } -//------------------------------------------------------------------------------------------------ -bool isSpecialRootDir(aiString &texName) { - if (texName.length < 2) { - return false; - } - - if (texName.data[0] = '/' || texName.data[1] == '/') { - return true; - } - - return false; -} - //------------------------------------------------------------------------------------------------ void OpenGEXImporter::handleTextureNode( ODDLParser::DDLNode *node, aiScene *pScene ) { if( NULL == node ) { From 7c3475c002e7e3681915512a4139caef855fbbeb Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 15:38:30 +0100 Subject: [PATCH 3/8] Coverity findings: fix resource leak in PlyLoader.cpp. --- code/PlyLoader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/PlyLoader.cpp b/code/PlyLoader.cpp index f86ddcead..eaa919277 100644 --- a/code/PlyLoader.cpp +++ b/code/PlyLoader.cpp @@ -312,6 +312,7 @@ void PLYImporter::ConvertMeshes(std::vector* avFaces, p_pcOut->mNumVertices = iNum; if( 0 == iNum ) { // nothing to do delete[] aiSplit; // cleanup + delete p_pcOut; return; } p_pcOut->mVertices = new aiVector3D[iNum]; From 0f1874d954cf95519857e1586a353aeaa25ad08a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 16:33:54 +0100 Subject: [PATCH 4/8] coverity findings: initialize index counter in line splitter. --- code/LineSplitter.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/code/LineSplitter.h b/code/LineSplitter.h index b517bd2be..ea4a9028f 100644 --- a/code/LineSplitter.h +++ b/code/LineSplitter.h @@ -83,7 +83,8 @@ public: note: trim is *always* assumed true if skyp_empty_lines==true */ LineSplitter(StreamReaderLE& stream, bool skip_empty_lines = true, bool trim = true) - : stream(stream) + : idx( 0 ) + , stream(stream) , swallow() , skip_empty_lines(skip_empty_lines) , trim(trim) @@ -94,6 +95,10 @@ public: idx = 0; } + ~LineSplitter() { + // empty + } + public: // ----------------------------------------- @@ -227,7 +232,10 @@ public: } private: + LineSplitter( const LineSplitter & ); + LineSplitter &operator = ( const LineSplitter & ); +private: line_idx idx; std::string cur; StreamReaderLE& stream; From e1818d8ab6e2c987bc802f9c3239f57e7e36379b Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 19:43:57 +0100 Subject: [PATCH 5/8] coverity findings: initialize lookup table for materials. --- code/ProcessHelper.cpp | 16 +++++++++++----- code/RemoveRedundantMaterials.cpp | 20 +++++++++++--------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/code/ProcessHelper.cpp b/code/ProcessHelper.cpp index cb38d96ef..3a774e7b8 100644 --- a/code/ProcessHelper.cpp +++ b/code/ProcessHelper.cpp @@ -95,12 +95,16 @@ void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& } // ------------------------------------------------------------------------------- -void FindSceneCenter (aiScene* scene, aiVector3D& out, aiVector3D& min, aiVector3D& max) -{ - if (scene->mNumMeshes == 0) return; +void FindSceneCenter (aiScene* scene, aiVector3D& out, aiVector3D& min, aiVector3D& max) { + if ( NULL == scene ) { + return; + } + + if ( 0 == scene->mNumMeshes ) { + return; + } FindMeshCenter(scene->mMeshes[0], out, min, max); - for (unsigned int i = 1; i < scene->mNumMeshes; ++i) - { + for (unsigned int i = 1; i < scene->mNumMeshes; ++i) { aiVector3D tout, tmin, tmax; FindMeshCenter(scene->mMeshes[i], tout, tmin, tmax); if (min[0] > tmin[0]) min[0] = tmin[0]; @@ -151,6 +155,8 @@ float ComputePositionEpsilon(const aiMesh* pMesh) // ------------------------------------------------------------------------------- float ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num) { + ai_assert( NULL != pMeshes ); + const float epsilon = 1e-4f; // calculate the position bounds so we have a reliable epsilon to check position differences against diff --git a/code/RemoveRedundantMaterials.cpp b/code/RemoveRedundantMaterials.cpp index 290396f20..3a8bb065d 100644 --- a/code/RemoveRedundantMaterials.cpp +++ b/code/RemoveRedundantMaterials.cpp @@ -55,7 +55,7 @@ using namespace Assimp; // ------------------------------------------------------------------------------------------------ // Constructor to be privately used by Importer RemoveRedundantMatsProcess::RemoveRedundantMatsProcess() -{ +: configFixedMaterials() { // nothing to do here } @@ -126,16 +126,18 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) } } - // TODO: reimplement this algorithm to work in-place - unsigned int* aiMappingTable = new unsigned int[pScene->mNumMaterials]; + // TODO: re-implement this algorithm to work in-place + unsigned int *aiMappingTable = new unsigned int[pScene->mNumMaterials]; + for ( unsigned int i=0; imNumMaterials; i++ ) { + aiMappingTable[ i ] = 0; + } unsigned int iNewNum = 0; // Iterate through all materials and calculate a hash for them // store all hashes in a list and so a quick search whether // we do already have a specific hash. This allows us to // determine which materials are identical. - uint32_t* aiHashes; - aiHashes = new uint32_t[pScene->mNumMaterials]; + uint32_t *aiHashes = new uint32_t[ pScene->mNumMaterials ];; for (unsigned int i = 0; i < pScene->mNumMaterials;++i) { // No mesh is referencing this material, remove it. @@ -177,18 +179,18 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) // generate new names for all modified materials const unsigned int idx = aiMappingTable[p]; - if (ppcMaterials[idx]) - { + if (ppcMaterials[idx]) { aiString sz; sz.length = ::sprintf(sz.data,"JoinedMaterial_#%u",p); ((aiMaterial*)ppcMaterials[idx])->AddProperty(&sz,AI_MATKEY_NAME); - } - else + } else { ppcMaterials[idx] = pScene->mMaterials[p]; + } } // update all material indices for (unsigned int p = 0; p < pScene->mNumMeshes;++p) { aiMesh* mesh = pScene->mMeshes[p]; + ai_assert( NULL!=mesh ); mesh->mMaterialIndex = aiMappingTable[mesh->mMaterialIndex]; } // delete the old material list From 1ea1f6dcfa35a36a2d66db814eab1f5cfaf7c4da Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 20:02:35 +0100 Subject: [PATCH 6/8] coverity findings: add missind intialization in STEPFile. --- code/STEPFile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/code/STEPFile.h b/code/STEPFile.h index ae7df67da..d707fed5b 100644 --- a/code/STEPFile.h +++ b/code/STEPFile.h @@ -863,6 +863,7 @@ namespace STEP { : reader(reader) , splitter(*reader,true,true) , evaluated_count() + , schema( NULL ) {} public: From 56e9a9168c7a4b719ce8411a37d662f4bcfaaa59 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 20:04:16 +0100 Subject: [PATCH 7/8] coverity findings: add missing initializations. --- code/DXFHelper.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/DXFHelper.h b/code/DXFHelper.h index a438c6de8..29e082e79 100644 --- a/code/DXFHelper.h +++ b/code/DXFHelper.h @@ -66,6 +66,8 @@ public: LineReader(StreamReaderLE& reader) // do NOT skip empty lines. In DXF files, they count as valid data. : splitter(reader,false,true) + , groupcode( 0 ) + , value() , end() { } From 043fef6d213f1a253285ae6fccf2ac366da9ce75 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 30 Dec 2015 20:39:58 +0100 Subject: [PATCH 8/8] coverity findings: fix resource leak in MakeVerboseFormat. --- code/MakeVerboseFormat.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/MakeVerboseFormat.cpp b/code/MakeVerboseFormat.cpp index 03f9c074d..0d625986d 100644 --- a/code/MakeVerboseFormat.cpp +++ b/code/MakeVerboseFormat.cpp @@ -172,13 +172,14 @@ bool MakeVerboseFormatProcess::MakeVerboseFormat(aiMesh* pcMesh) for (unsigned int i = 0;i < pcMesh->mNumBones;++i) { delete pcMesh->mBones[i]->mWeights; - if (!newWeights[i].empty()) - { + if (!newWeights[i].empty()) { pcMesh->mBones[i]->mWeights = new aiVertexWeight[newWeights[i].size()]; - memcpy(pcMesh->mBones[i]->mWeights,&newWeights[i][0], + memcpy(pcMesh->mBones[i]->mWeights, &newWeights[i][0], sizeof(aiVertexWeight) * newWeights[i].size()); + delete[] newWeights; + } else { + pcMesh->mBones[i]->mWeights = NULL; } - else pcMesh->mBones[i]->mWeights = NULL; } // delete the old members