From a15bfceb7e8365823e1d85abef254fe09b197c2d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 17 Oct 2017 18:37:40 +0300 Subject: [PATCH 01/42] Travis: Add static analysis to build --- .travis.sh | 15 +++++++++++++++ .travis.yml | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.travis.sh b/.travis.sh index 75f00ec60..cc981a453 100755 --- a/.travis.sh +++ b/.travis.sh @@ -43,9 +43,24 @@ if [ $ANDROID ]; then ant -v -Dmy.dir=${TRAVIS_BUILD_DIR} -f ${TRAVIS_BUILD_DIR}/port/jassimp/build.xml ndk-jni fi if [ "$TRAVIS_OS_NAME" = "linux" ]; then + if [ $ANALYZE = "ON" ] ; then + if [ "$CC" = "clang" ]; then + scan-build cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=OFF + scan-build --status-bugs make -j2 + else + cppcheck --version + generate \ + && cppcheck --error-exitcode=1 -j2 -Iinclude -Icode code 2> cppcheck.txt + if [ -s cppcheck.txt ]; then + cat cppcheck.txt + exit 1 + fi + fi + else generate \ && make -j4 \ && sudo make install \ && sudo ldconfig \ && (cd test/unit; ../../bin/unit) + fi fi diff --git a/.travis.yml b/.travis.yml index 95e2fc164..e5477a543 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: cpp cache: ccache before_install: - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq && sudo apt-get install cmake && sudo apt-get install cmake python3 && sudo apt-get install -qq freeglut3-dev libxmu-dev libxi-dev ; echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- ; fi + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq && sudo apt-get install cmake cppcheck && sudo apt-get install cmake python3 && sudo apt-get install -qq freeglut3-dev libxmu-dev libxi-dev ; echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca- ; fi - 'if [ "$TRAVIS_OS_NAME" = "osx" ]; then if brew ls --versions cmake > /dev/null; then echo cmake already installed.; @@ -39,6 +39,12 @@ matrix: - os: linux compiler: gcc env: SHARED_BUILD=ON + - os: linux + compiler: gcc + env: ANALYZE=ON + - os: linux + compiler: clang + env: ANALYZE=ON - os: linux compiler: clang env: ASAN=ON From 76919e87eacf2f201ac8055ab002a7be5dc4d28b Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 17 Oct 2017 19:01:36 +0300 Subject: [PATCH 02/42] fast_atof: Silence some uninitialized variable warnings --- code/fast_atof.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/fast_atof.h b/code/fast_atof.h index be1e59221..058a7ff87 100644 --- a/code/fast_atof.h +++ b/code/fast_atof.h @@ -360,7 +360,7 @@ inline const char* fast_atoreal_move(const char* c, Real& out, bool check_comma // The same but more human. inline ai_real fast_atof(const char* c) { - ai_real ret; + ai_real ret(0.0); fast_atoreal_move(c, ret); return ret; } @@ -368,7 +368,7 @@ inline ai_real fast_atof(const char* c) inline ai_real fast_atof( const char* c, const char** cout) { - ai_real ret; + ai_real ret(0.0); *cout = fast_atoreal_move(c, ret); return ret; @@ -376,7 +376,7 @@ inline ai_real fast_atof( const char* c, const char** cout) inline ai_real fast_atof( const char** inout) { - ai_real ret; + ai_real ret(0.0); *inout = fast_atoreal_move(*inout, ret); return ret; From 59d1a1d8198fc25bb1f2a479fd5598d3cc28d629 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 17 Oct 2017 19:02:39 +0300 Subject: [PATCH 03/42] Travis: Move slower builds earlier to improve parallelization --- .travis.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index e5477a543..9265dfb38 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,15 +33,6 @@ env: matrix: include: - - os: linux - compiler: gcc - env: DISABLE_EXPORTERS=YES ENABLE_COVERALLS=ON - - os: linux - compiler: gcc - env: SHARED_BUILD=ON - - os: linux - compiler: gcc - env: ANALYZE=ON - os: linux compiler: clang env: ANALYZE=ON @@ -54,6 +45,15 @@ matrix: - os: linux compiler: clang env: SHARED_BUILD=ON + - os: linux + compiler: gcc + env: ANALYZE=ON + - os: linux + compiler: gcc + env: DISABLE_EXPORTERS=YES ENABLE_COVERALLS=ON + - os: linux + compiler: gcc + env: SHARED_BUILD=ON install: - if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi From 35907e344622d78a2073fd0214765365ba42473d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 17 Oct 2017 19:29:54 +0300 Subject: [PATCH 04/42] Travis: Disable unit tests in scan-build config --- .travis.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.sh b/.travis.sh index cc981a453..fb42bd40d 100755 --- a/.travis.sh +++ b/.travis.sh @@ -45,7 +45,7 @@ fi if [ "$TRAVIS_OS_NAME" = "linux" ]; then if [ $ANALYZE = "ON" ] ; then if [ "$CC" = "clang" ]; then - scan-build cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=OFF + scan-build cmake -G "Unix Makefiles" -DBUILD_SHARED_LIBS=OFF -DASSIMP_BUILD_TESTS=OFF scan-build --status-bugs make -j2 else cppcheck --version From 266e3b29a85fb56665df51775b6b08443bb6fdad Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 17 Oct 2017 19:48:08 +0300 Subject: [PATCH 05/42] RemoveRedundantMaterials: Set pointer to nullptr after deleting it --- code/RemoveRedundantMaterials.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/RemoveRedundantMaterials.cpp b/code/RemoveRedundantMaterials.cpp index 154bf63ca..8ea699f3d 100644 --- a/code/RemoveRedundantMaterials.cpp +++ b/code/RemoveRedundantMaterials.cpp @@ -145,6 +145,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) if (!abReferenced[i]) { ++unreferencedRemoved; delete pScene->mMaterials[i]; + pScene->mMaterials[i] = nullptr; continue; } @@ -158,6 +159,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) me = 0; aiMappingTable[i] = aiMappingTable[a]; delete pScene->mMaterials[i]; + pScene->mMaterials[i] = nullptr; break; } } From c774e864a0a7c79eb6183ddf1b95b1ed33b8bb79 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 24 Oct 2017 18:39:05 +0300 Subject: [PATCH 06/42] Remove some dead assignments --- code/Bitmap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/Bitmap.cpp b/code/Bitmap.cpp index b1cf8a409..76994513e 100644 --- a/code/Bitmap.cpp +++ b/code/Bitmap.cpp @@ -102,7 +102,7 @@ namespace Assimp { offset += Copy(&data[offset], header.size); offset += Copy(&data[offset], header.reserved1); offset += Copy(&data[offset], header.reserved2); - offset += Copy(&data[offset], header.offset); + Copy(&data[offset], header.offset); file->Write(data, Header::header_size, 1); } @@ -122,7 +122,7 @@ namespace Assimp { offset += Copy(&data[offset], dib.x_resolution); offset += Copy(&data[offset], dib.y_resolution); offset += Copy(&data[offset], dib.nb_colors); - offset += Copy(&data[offset], dib.nb_important_colors); + Copy(&data[offset], dib.nb_important_colors); file->Write(data, DIB::dib_size, 1); } From 95f2319b41b65ff6f1947780cd328b0e05089a14 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 24 Oct 2017 19:51:12 +0300 Subject: [PATCH 07/42] ImproveCacheLocality: Add assertion to silence a static analyzer warning --- code/ImproveCacheLocality.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ImproveCacheLocality.cpp b/code/ImproveCacheLocality.cpp index 7f0727e8b..2ac32aa84 100644 --- a/code/ImproveCacheLocality.cpp +++ b/code/ImproveCacheLocality.cpp @@ -223,6 +223,7 @@ float ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int mesh iMaxRefTris = std::max(iMaxRefTris,*piCur); } } + ai_assert(iMaxRefTris > 0); unsigned int* piCandidates = new unsigned int[iMaxRefTris*3]; unsigned int iCacheMisses = 0; From c51b92cfa32adfd670a284c9b903441f09984fd4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 24 Oct 2017 20:05:15 +0300 Subject: [PATCH 08/42] RemoveRedundantMaterials: Add assertion to silence a static analyzer warning --- code/RemoveRedundantMaterials.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/RemoveRedundantMaterials.cpp b/code/RemoveRedundantMaterials.cpp index 8ea699f3d..c6319f892 100644 --- a/code/RemoveRedundantMaterials.cpp +++ b/code/RemoveRedundantMaterials.cpp @@ -171,6 +171,7 @@ void RemoveRedundantMatsProcess::Execute( aiScene* pScene) // If the new material count differs from the original, // we need to rebuild the material list and remap mesh material indexes. if (iNewNum != pScene->mNumMaterials) { + ai_assert(iNewNum > 0); aiMaterial** ppcMaterials = new aiMaterial*[iNewNum]; ::memset(ppcMaterials,0,sizeof(void*)*iNewNum); for (unsigned int p = 0; p < pScene->mNumMaterials;++p) From a7fccf8f3352bc3e20689a46d4a8d0ce30384cb8 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 18:18:01 +0200 Subject: [PATCH 09/42] OptimizeGraph: Fix possible null pointer dereference --- code/OptimizeGraph.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/OptimizeGraph.cpp b/code/OptimizeGraph.cpp index 04971af5e..0e510e5ea 100644 --- a/code/OptimizeGraph.cpp +++ b/code/OptimizeGraph.cpp @@ -233,11 +233,13 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list& no nd->mNumChildren = static_cast(child_nodes.size()); + if (nd->mChildren) { aiNode** tmp = nd->mChildren; for (std::list::iterator it = child_nodes.begin(); it != child_nodes.end(); ++it) { aiNode* node = *tmp++ = *it; node->mParent = nd; } + } nodes_out += static_cast(child_nodes.size()); } From bd0d47c5fc85dd19aec48a2d993c43fd0f5b608f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 18:18:34 +0200 Subject: [PATCH 10/42] Whitespace --- code/OptimizeGraph.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/OptimizeGraph.cpp b/code/OptimizeGraph.cpp index 0e510e5ea..11a6fcf65 100644 --- a/code/OptimizeGraph.cpp +++ b/code/OptimizeGraph.cpp @@ -234,11 +234,11 @@ void OptimizeGraphProcess::CollectNewChildren(aiNode* nd, std::list& no nd->mNumChildren = static_cast(child_nodes.size()); if (nd->mChildren) { - aiNode** tmp = nd->mChildren; - for (std::list::iterator it = child_nodes.begin(); it != child_nodes.end(); ++it) { - aiNode* node = *tmp++ = *it; - node->mParent = nd; - } + aiNode** tmp = nd->mChildren; + for (std::list::iterator it = child_nodes.begin(); it != child_nodes.end(); ++it) { + aiNode* node = *tmp++ = *it; + node->mParent = nd; + } } nodes_out += static_cast(child_nodes.size()); From 2c7770eed549bf3137c89c32e0f6012fa95b0c1e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 18:38:24 +0200 Subject: [PATCH 11/42] AMFImporter: Add a block --- code/AMFImporter_Postprocess.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp index 0e639026c..3737116f2 100644 --- a/code/AMFImporter_Postprocess.cpp +++ b/code/AMFImporter_Postprocess.cpp @@ -281,8 +281,9 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string& { if(!pID.empty()) { - for(size_t idx_target = pOffset, idx_src = 0; idx_target < tex_size; idx_target += pStep, idx_src++) + for(size_t idx_target = pOffset, idx_src = 0; idx_target < tex_size; idx_target += pStep, idx_src++) { converted_texture.Data[idx_target] = src_texture[pSrcTexNum]->Data.at(idx_src); + } } };// auto CopyTextureData = [&](const size_t pOffset, const size_t pStep, const uint8_t pSrcTexNum) -> void From 856d402b59725b99b9af21e3831c8cdb33383989 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 18:44:16 +0200 Subject: [PATCH 12/42] AMFImporter: Add assertion to silence a static analyzer warning --- code/AMFImporter_Postprocess.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/AMFImporter_Postprocess.cpp b/code/AMFImporter_Postprocess.cpp index 3737116f2..991eb97e7 100644 --- a/code/AMFImporter_Postprocess.cpp +++ b/code/AMFImporter_Postprocess.cpp @@ -282,7 +282,9 @@ size_t AMFImporter::PostprocessHelper_GetTextureID_Or_Create(const std::string& if(!pID.empty()) { for(size_t idx_target = pOffset, idx_src = 0; idx_target < tex_size; idx_target += pStep, idx_src++) { - converted_texture.Data[idx_target] = src_texture[pSrcTexNum]->Data.at(idx_src); + CAMFImporter_NodeElement_Texture* tex = src_texture[pSrcTexNum]; + ai_assert(tex); + converted_texture.Data[idx_target] = tex->Data.at(idx_src); } } };// auto CopyTextureData = [&](const size_t pOffset, const size_t pStep, const uint8_t pSrcTexNum) -> void From 4c9f1691091b88a61e60f72b4365cf72ff4ea333 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 18:45:02 +0200 Subject: [PATCH 13/42] ASE: Add assertion to silence a static analyzer warning --- code/ASELoader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ASELoader.cpp b/code/ASELoader.cpp index 16b3c4ad9..65935f48f 100644 --- a/code/ASELoader.cpp +++ b/code/ASELoader.cpp @@ -1021,6 +1021,7 @@ void ASEImporter::ConvertMeshes(ASE::Mesh& mesh, std::vector& avOutMesh // convert bones, if existing if (!mesh.mBones.empty()) { + ai_assert(avOutputBones); // check whether there is a vertex weight for this vertex index if (iIndex2 < mesh.mBoneVertices.size()) { From 437816fc33d4e1ef60d5470c467d2300d2d67827 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 19:05:01 +0200 Subject: [PATCH 14/42] AssbinExporter: Add assertion to silence a static analyzer warning --- code/AssbinExporter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/AssbinExporter.cpp b/code/AssbinExporter.cpp index 6bee6d6d1..bcac2e08f 100644 --- a/code/AssbinExporter.cpp +++ b/code/AssbinExporter.cpp @@ -171,6 +171,7 @@ inline size_t Write(IOStream * stream, const aiQuaternion& v) t += Write(stream,v.x); t += Write(stream,v.y); t += Write(stream,v.z); + ai_assert(t == 16); return 16; } From a276a027263f8cd6eefc97d524bdab952ec04d6d Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 19:11:08 +0200 Subject: [PATCH 15/42] IRRLoader: Fix confusing boolean casting --- code/IRRLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/IRRLoader.cpp b/code/IRRLoader.cpp index 5113ab70d..c29d5b072 100644 --- a/code/IRRLoader.cpp +++ b/code/IRRLoader.cpp @@ -394,7 +394,7 @@ void IRRImporter::ComputeAnimations(Node* root, aiNode* real, std::vector Date: Tue, 7 Nov 2017 19:12:12 +0200 Subject: [PATCH 16/42] LWO: Reduce scope of a variable --- code/LWOAnimation.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/LWOAnimation.cpp b/code/LWOAnimation.cpp index 61c696453..4b5338f7a 100644 --- a/code/LWOAnimation.cpp +++ b/code/LWOAnimation.cpp @@ -446,8 +446,6 @@ void AnimResolver::GetKeys(std::vector& out, // Iterate through all three arrays at once - it's tricky, but // rather interesting to implement. - double lasttime = std::min(envl_x->keys[0].time,std::min(envl_y->keys[0].time,envl_z->keys[0].time)); - cur_x = envl_x->keys.begin(); cur_y = envl_y->keys.begin(); cur_z = envl_z->keys.begin(); @@ -503,7 +501,7 @@ void AnimResolver::GetKeys(std::vector& out, InterpolateTrack(out,fill,(end_y ? (*cur_x) : (*cur_y)).time); } } - lasttime = fill.mTime; + double lasttime = fill.mTime; out.push_back(fill); if (lasttime >= (*cur_x).time) { From 2b93a210c9a0142599a19d61d547f47e93c76278 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 19:12:44 +0200 Subject: [PATCH 17/42] NFF: Reduce scope of a variable --- code/NFFLoader.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index fa005ede4..b6dd2fb33 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -243,8 +243,6 @@ void NFFImporter::InternReadFile( const std::string& pFile, if( !file.get()) throw DeadlyImportError( "Failed to open NFF file " + pFile + "."); - unsigned int m = (unsigned int)file->FileSize(); - // allocate storage and copy the contents of the file to a memory buffer // (terminate it with zero) std::vector mBuffer2; @@ -469,7 +467,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, for (unsigned int a = 0; a < numIdx;++a) { SkipSpaces(sz,&sz); - m = ::strtoul10(sz,&sz); + unsigned int m = ::strtoul10(sz,&sz); if (m >= (unsigned int)tempPositions.size()) { DefaultLogger::get()->error("NFF2: Vertex index overflow"); @@ -635,7 +633,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, for (std::vector::const_iterator it = tempIdx.begin(), end = tempIdx.end(); it != end;++it) { - m = *it; + unsigned int m = *it; // copy colors -vertex color specifications override polygon color specifications if (hasColor) @@ -735,7 +733,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, sz = &line[1];out = currentMesh; } SkipSpaces(sz,&sz); - m = strtoul10(sz); + unsigned int m = strtoul10(sz); // ---- flip the face order out->vertices.resize(out->vertices.size()+m); @@ -1128,7 +1126,8 @@ void NFFImporter::InternReadFile( const std::string& pFile, if (!pScene->mNumMeshes)throw DeadlyImportError("NFF: No meshes loaded"); pScene->mMeshes = new aiMesh*[pScene->mNumMeshes]; pScene->mMaterials = new aiMaterial*[pScene->mNumMaterials = pScene->mNumMeshes]; - for (it = meshes.begin(), m = 0; it != end;++it) + unsigned int m = 0; + for (it = meshes.begin(); it != end;++it) { if ((*it).faces.empty())continue; From d24e0d44b28b05f18498928dc0abb65f24fbdb09 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 19:15:06 +0200 Subject: [PATCH 18/42] Raw: Fix misleading indentation warning --- code/RawLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/RawLoader.cpp b/code/RawLoader.cpp index e14b5140d..2b76455d7 100644 --- a/code/RawLoader.cpp +++ b/code/RawLoader.cpp @@ -260,7 +260,7 @@ void RAWImporter::InternReadFile( const std::string& pFile, node = *cc = new aiNode(); node->mParent = pScene->mRootNode; } - else node = *cc;++cc; + else node = *cc; node->mName.Set(outGroup.name); // add all meshes From 3f299b2a2bf56d75bb3336bda19dab445be66fcd Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 19:32:33 +0200 Subject: [PATCH 19/42] NFF: Split up some complicated assignments --- code/NFFLoader.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index b6dd2fb33..396fb28bf 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -1079,7 +1079,8 @@ void NFFImporter::InternReadFile( const std::string& pFile, // generate the camera if (hasCam) { - aiNode* nd = *ppcChildren = new aiNode(); + aiNode* nd = new aiNode(); + *ppcChildren = nd; nd->mName.Set(""); nd->mParent = root; @@ -1109,7 +1110,8 @@ void NFFImporter::InternReadFile( const std::string& pFile, { const Light& l = lights[i]; - aiNode* nd = *ppcChildren = new aiNode(); + aiNode* nd = new aiNode(); + *ppcChildren = nd; nd->mParent = root; nd->mName.length = ::ai_snprintf(nd->mName.data,1024,"",i); From f90019bc1ee8a6283dff09dc02977aff42fee1bb Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 7 Nov 2017 19:38:31 +0200 Subject: [PATCH 20/42] NFF: Add assertions to silence static analyzer warnings --- code/NFFLoader.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/NFFLoader.cpp b/code/NFFLoader.cpp index 396fb28bf..a51c500f1 100644 --- a/code/NFFLoader.cpp +++ b/code/NFFLoader.cpp @@ -1079,6 +1079,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, // generate the camera if (hasCam) { + ai_assert(ppcChildren); aiNode* nd = new aiNode(); *ppcChildren = nd; nd->mName.Set(""); @@ -1104,6 +1105,7 @@ void NFFImporter::InternReadFile( const std::string& pFile, // generate light sources if (!lights.empty()) { + ai_assert(ppcChildren); pScene->mNumLights = (unsigned int)lights.size(); pScene->mLights = new aiLight*[pScene->mNumLights]; for (unsigned int i = 0; i < pScene->mNumLights;++i,++ppcChildren) From f470b8466fb52b13ff3e11c917072fc44d271ac4 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 18:42:04 +0200 Subject: [PATCH 21/42] GLTF2: Fix signed/unsigned warning --- code/glTF2Asset.inl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index 37a8fc662..f37d592c1 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -204,7 +204,7 @@ unsigned int LazyDict::Remove(const char* id) throw DeadlyExportError("GLTF: Object with id \"" + std::string(id) + "\" is not found"); } - const int index = it->second; + const unsigned int index = it->second; mAsset.mUsedIds[id] = false; mObjsById.erase(id); From 97843f19d2301b489e4bd65eb7fa6c2f7ca4c5dc Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 18:46:27 +0200 Subject: [PATCH 22/42] OpenGEX: Add assertion to silence a static analyzer warning --- code/OpenGEXImporter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/OpenGEXImporter.cpp b/code/OpenGEXImporter.cpp index 52e9ce501..025356c1d 100644 --- a/code/OpenGEXImporter.cpp +++ b/code/OpenGEXImporter.cpp @@ -652,6 +652,8 @@ static void setMatrix( aiNode *node, DataArrayList *transformData ) { i++; } + ai_assert(i == 16); + node->mTransformation.a1 = m[ 0 ]; node->mTransformation.a2 = m[ 4 ]; node->mTransformation.a3 = m[ 8 ]; From b49a4e133884ba2ed73cd16cd07250b4d875dd70 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 18:48:07 +0200 Subject: [PATCH 23/42] PLY: Remove dead assignment and reduce scope of a variable --- code/PlyParser.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/PlyParser.cpp b/code/PlyParser.cpp index 65de665ab..6321821d2 100644 --- a/code/PlyParser.cpp +++ b/code/PlyParser.cpp @@ -671,7 +671,6 @@ bool PLY::ElementInstanceList::ParseInstanceList( PLYImporter* loader) { ai_assert(NULL != pcElement); - const char* pCur = (const char*)&buffer[0]; // parse all elements if (EEST_INVALID == pcElement->eSemantic || pcElement->alProperties.empty()) @@ -683,11 +682,11 @@ bool PLY::ElementInstanceList::ParseInstanceList( PLY::DOM::SkipComments(buffer); PLY::DOM::SkipLine(buffer); streamBuffer.getNextLine(buffer); - pCur = (buffer.empty()) ? NULL : (const char*)&buffer[0]; } } else { + const char* pCur = (const char*)&buffer[0]; // be sure to have enough storage for (unsigned int i = 0; i < pcElement->NumOccur; ++i) { From ef0af40f9005dae1017a5a44131e15a7c3322c1f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 18:53:08 +0200 Subject: [PATCH 24/42] IFC: Remove dead code --- code/IFCOpenings.cpp | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/code/IFCOpenings.cpp b/code/IFCOpenings.cpp index 45e0d1b90..4d57cd473 100644 --- a/code/IFCOpenings.cpp +++ b/code/IFCOpenings.cpp @@ -1499,7 +1499,7 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,const std: IfcVector3 wall_extrusion; - bool do_connections = false, first = true; + bool first = true; try { @@ -1527,7 +1527,6 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,const std: if (first) { first = false; if (dot > 0.f) { - do_connections = true; wall_extrusion = t.extrusionDir; if (is_extruded_side) { wall_extrusion = - wall_extrusion; @@ -1607,44 +1606,6 @@ bool TryAddOpenings_Poly2Tri(const std::vector& openings,const std: old_verts.swap(curmesh.verts); old_vertcnt.swap(curmesh.vertcnt); - - // add connection geometry to close the adjacent 'holes' for the openings - // this should only be done from one side of the wall or the polygons - // would be emitted twice. - if (false && do_connections) { - - std::vector tmpvec; - for(ClipperLib::Polygon& opening : holes_union) { - - ai_assert(ClipperLib::Orientation(opening)); - - tmpvec.clear(); - - for(ClipperLib::IntPoint& point : opening) { - - tmpvec.push_back( minv * IfcVector3( - vmin.x + from_int64(point.X) * vmax.x, - vmin.y + from_int64(point.Y) * vmax.y, - coord)); - } - - for(size_t i = 0, size = tmpvec.size(); i < size; ++i) { - const size_t next = (i+1)%size; - - curmesh.vertcnt.push_back(4); - - const IfcVector3& in_world = tmpvec[i]; - const IfcVector3& next_world = tmpvec[next]; - - // Assumptions: no 'partial' openings, wall thickness roughly the same across the wall - curmesh.verts.push_back(in_world); - curmesh.verts.push_back(in_world+wall_extrusion); - curmesh.verts.push_back(next_world+wall_extrusion); - curmesh.verts.push_back(next_world); - } - } - } - std::vector< std::vector > contours; for(ClipperLib::ExPolygon& clip : clipped) { From 583d3f88b8cdb1719c47cb2bf84ed1074a659497 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 19:05:53 +0200 Subject: [PATCH 25/42] FBX: Remove dead assignment --- code/FBXConverter.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index a1e3ae07c..a5e44a607 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -566,7 +566,6 @@ void Converter::ConvertNodes( uint64_t id, aiNode& parent, const aiMatrix4x4& pa if ( !name_carrier ) { nodes_chain.push_back( new aiNode( original_name ) ); - name_carrier = nodes_chain.back(); } //setup metadata on newest node From e47bf932e8b8a7780e996d9800a5414c3d3cbd17 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 19:08:41 +0200 Subject: [PATCH 26/42] SIBImporter: Add assertions to silence static analyzer warnings --- code/SIBImporter.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/SIBImporter.cpp b/code/SIBImporter.cpp index e85c9bdcb..2127e2e0c 100644 --- a/code/SIBImporter.cpp +++ b/code/SIBImporter.cpp @@ -902,6 +902,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, // Add nodes for each object. for (size_t n=0;nmChildren); SIBObject& obj = sib.objs[n]; aiNode* node = new aiNode; root->mChildren[childIdx++] = node; @@ -926,6 +927,7 @@ void SIBImporter::InternReadFile(const std::string& pFile, // (no transformation as the light is already in world space) for (size_t n=0;nmChildren); aiLight* light = sib.lights[n]; if ( nullptr != light ) { aiNode* node = new aiNode; From 66c18cc4062ff68ef1fc7dbe1deb333c2be1f0e2 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 19:13:14 +0200 Subject: [PATCH 27/42] TerragenLoader: Remove unused variable --- code/TerragenLoader.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/TerragenLoader.cpp b/code/TerragenLoader.cpp index ecf33aae9..0126229ac 100644 --- a/code/TerragenLoader.cpp +++ b/code/TerragenLoader.cpp @@ -141,9 +141,6 @@ void TerragenImporter::InternReadFile( const std::string& pFile, throw DeadlyImportError( "TER: Magic string \'TERRAIN\' not found" ); unsigned int x = 0,y = 0,mode = 0; - float rad = 6370.f; - (void)rad; - aiNode* root = pScene->mRootNode = new aiNode(); root->mName.Set(""); @@ -187,7 +184,7 @@ void TerragenImporter::InternReadFile( const std::string& pFile, // mapping == 1: earth radius else if (!::strncmp(head,AI_TERR_CHUNK_CRAD,4)) { - rad = reader.GetF4(); + reader.GetF4(); } // mapping mode else if (!::strncmp(head,AI_TERR_CHUNK_CRVM,4)) From f475803f931f45add900090d4b8f9d81b1a9c85e Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 19:24:34 +0200 Subject: [PATCH 28/42] X3DImporter: Add assertions to silence static analyzer warnings --- code/X3DImporter_Postprocess.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/X3DImporter_Postprocess.cpp b/code/X3DImporter_Postprocess.cpp index 0e3f3a8ae..390ef8995 100644 --- a/code/X3DImporter_Postprocess.cpp +++ b/code/X3DImporter_Postprocess.cpp @@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "X3DImporter.hpp" // Header files, Assimp. +#include #include "StandardShapes.h" #include "StringUtils.h" @@ -357,6 +358,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // copy additional information from children for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) { + ai_assert(*pMesh); if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) @@ -389,6 +391,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // copy additional information from children for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) { + ai_assert(*pMesh); if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) MeshGeometry_AddColor(**pMesh, tnemesh.CoordIndex, tnemesh.ColorIndex, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) @@ -446,6 +449,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // copy additional information from children for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) { + ai_assert(*pMesh); if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, true); else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) @@ -475,6 +479,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // copy additional information from children for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) { + ai_assert(*pMesh); if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, true); else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) @@ -550,6 +555,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // copy additional information from children for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) { + ai_assert(*pMesh); if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) @@ -584,6 +590,7 @@ void X3DImporter::Postprocess_BuildMesh(const CX3DImporter_NodeElement& pNodeEle // copy additional information from children for(std::list::iterator ch_it = tnemesh.Child.begin(); ch_it != tnemesh.Child.end(); ch_it++) { + ai_assert(*pMesh); if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_Color) MeshGeometry_AddColor(**pMesh, ((CX3DImporter_NodeElement_Color*)*ch_it)->Value, tnemesh.ColorPerVertex); else if((*ch_it)->Type == CX3DImporter_NodeElement::ENET_ColorRGBA) From 9dadec77364816acfdabaa382a24bbc4b04d5ffa Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Tue, 14 Nov 2017 19:46:35 +0200 Subject: [PATCH 29/42] assimp_cmd: Add assertion to silence a static analyzer warning --- tools/assimp_cmd/WriteDumb.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index 3fe8b2c77..69d4efcc5 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -198,6 +198,7 @@ inline uint32_t Write(const aiQuaternion& v) t += Write(v.x); t += Write(v.y); t += Write(v.z); + ai_assert(t == 16); return 16; } From eb5f47f5c5b96af42c1633b371909b5c37ab6e90 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 11:58:13 +0200 Subject: [PATCH 30/42] OpenDDLParser: Fix potential memory leak --- contrib/openddlparser/code/OpenDDLParser.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index dab976fad..c42fc9d57 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -27,6 +27,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include #include #ifdef _WIN32 @@ -275,12 +276,12 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) { } delete id; - Name *name(ddl_nullptr); - in = OpenDDLParser::parseName(in, end, &name); + Name *name_(ddl_nullptr); + in = OpenDDLParser::parseName(in, end, &name_); + std::unique_ptr name(name_); if( ddl_nullptr != name && ddl_nullptr != node ) { const std::string nodeName( name->m_id->m_buffer ); node->setName( nodeName ); - delete name; } From 635a515e69af97793eec9f1b45a2e397cc3e2cfd Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:06:21 +0200 Subject: [PATCH 31/42] OpenDDLParser: Fix another potential memory leak --- contrib/openddlparser/code/OpenDDLParser.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index c42fc9d57..6e0e2322e 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -285,13 +285,15 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) { } - Property *first(ddl_nullptr); + std::unique_ptr first; in = lookForNextToken(in, end); if (*in == Grammar::OpenPropertyToken[0]) { in++; - Property *prop(ddl_nullptr), *prev(ddl_nullptr); + std::unique_ptr prop, prev; while (*in != Grammar::ClosePropertyToken[0] && in != end) { - in = OpenDDLParser::parseProperty(in, end, &prop); + Property *prop_(ddl_nullptr); + in = OpenDDLParser::parseProperty(in, end, &prop_); + prop.reset(prop_); in = lookForNextToken(in, end); if (*in != Grammar::CommaSeparator[0] && *in != Grammar::ClosePropertyToken[0]) { @@ -301,20 +303,20 @@ char *OpenDDLParser::parseHeader( char *in, char *end ) { if (ddl_nullptr != prop && *in != Grammar::CommaSeparator[0]) { if (ddl_nullptr == first) { - first = prop; + first = std::move(prop); } if (ddl_nullptr != prev) { - prev->m_next = prop; + prev->m_next = prop.release(); } - prev = prop; + prev = std::move(prop); } } ++in; } // set the properties - if (ddl_nullptr != first && ddl_nullptr != node) { - node->setProperties(first); + if (first && ddl_nullptr != node) { + node->setProperties(first.release()); } } From 58d5d04e82327d3884a2cdc2a9f45bc18beb9a46 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:06:30 +0200 Subject: [PATCH 32/42] OpenDDLParser: Remove dead assignment --- contrib/openddlparser/code/OpenDDLParser.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/openddlparser/code/OpenDDLParser.cpp b/contrib/openddlparser/code/OpenDDLParser.cpp index 6e0e2322e..caa281364 100644 --- a/contrib/openddlparser/code/OpenDDLParser.cpp +++ b/contrib/openddlparser/code/OpenDDLParser.cpp @@ -342,7 +342,6 @@ char *OpenDDLParser::parseStructure( char *in, char *end ) { } else { ++in; logInvalidTokenError( in, std::string( Grammar::OpenBracketToken ), m_logCallback ); - error = true; return ddl_nullptr; } in = lookForNextToken( in, end ); From be1d346c28c1ca0e7db109368285f90303cd00d9 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:12:06 +0200 Subject: [PATCH 33/42] Open3DGC: Add assertions to silence static analyzer warnings --- contrib/Open3DGC/o3dgcArithmeticCodec.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/Open3DGC/o3dgcArithmeticCodec.cpp b/contrib/Open3DGC/o3dgcArithmeticCodec.cpp index 1d160ba95..3597ec39a 100644 --- a/contrib/Open3DGC/o3dgcArithmeticCodec.cpp +++ b/contrib/Open3DGC/o3dgcArithmeticCodec.cpp @@ -820,6 +820,7 @@ namespace o3dgc for (unsigned n = 0; n < data_symbols; n++) total_count += (symbol_count[n] = (symbol_count[n] + 1) >> 1); } + assert(total_count > 0); // compute cumulative distribution, decoder table unsigned k, sum = 0, s = 0; unsigned scale = 0x80000000U / total_count; @@ -830,6 +831,7 @@ namespace o3dgc sum += symbol_count[k]; } else { + assert(decoder_table); for (k = 0; k < data_symbols; k++) { distribution[k] = (scale * sum) >> (31 - DM__LengthShift); sum += symbol_count[k]; From ef91211231c0ad730682fc3f553e4462356f0660 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:14:56 +0200 Subject: [PATCH 34/42] OpenDDLExport: Remove dead variable --- contrib/openddlparser/code/OpenDDLExport.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLExport.cpp b/contrib/openddlparser/code/OpenDDLExport.cpp index a85bc5676..bb6d5532f 100644 --- a/contrib/openddlparser/code/OpenDDLExport.cpp +++ b/contrib/openddlparser/code/OpenDDLExport.cpp @@ -135,10 +135,9 @@ bool OpenDDLExport::writeToStream( const std::string &statement ) { } bool OpenDDLExport::writeNode( DDLNode *node, std::string &statement ) { - bool success( true ); writeNodeHeader( node, statement ); if (node->hasProperties()) { - success |= writeProperties( node, statement ); + writeProperties( node, statement ); } writeLineEnd( statement ); From fc59f190ae5e6ced9242cb711633f4709a315c02 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:15:53 +0200 Subject: [PATCH 35/42] OpenDDLExport: Reduce scope of a variable --- contrib/openddlparser/code/OpenDDLExport.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/contrib/openddlparser/code/OpenDDLExport.cpp b/contrib/openddlparser/code/OpenDDLExport.cpp index bb6d5532f..e45fb041a 100644 --- a/contrib/openddlparser/code/OpenDDLExport.cpp +++ b/contrib/openddlparser/code/OpenDDLExport.cpp @@ -359,11 +359,10 @@ bool OpenDDLExport::writeValueArray( DataArrayList *al, std::string &statement ) } DataArrayList *nextDataArrayList = al ; - Value *nextValue( nextDataArrayList->m_dataList ); while (ddl_nullptr != nextDataArrayList) { if (ddl_nullptr != nextDataArrayList) { statement += "{ "; - nextValue = nextDataArrayList->m_dataList; + Value *nextValue( nextDataArrayList->m_dataList ); size_t idx( 0 ); while (ddl_nullptr != nextValue) { if (idx > 0) { From 11fdaa31bcadb05515bc9205eb5352f6f35e5a89 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:18:39 +0200 Subject: [PATCH 36/42] clipper: Add assertion to silence a static analyzer warning --- contrib/clipper/clipper.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/contrib/clipper/clipper.cpp b/contrib/clipper/clipper.cpp index 7d2af7d3a..d10cb1e5c 100644 --- a/contrib/clipper/clipper.cpp +++ b/contrib/clipper/clipper.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -2365,6 +2366,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) //ok, so far it looks like we're still in range of the horizontal edge if ( e->xcurr == horzEdge->xtop && !eMaxPair ) { + assert(horzEdge->nextInLML); if (SlopesEqual(*e, *horzEdge->nextInLML, m_UseFullRange)) { //if output polygons share an edge, they'll need joining later ... From 0bc259fd9541713e46810d0e0b1fe5ec79b6d3e6 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:30:18 +0200 Subject: [PATCH 37/42] unzip: Fix possibly uninitialized variables --- contrib/unzip/unzip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/unzip/unzip.c b/contrib/unzip/unzip.c index 085d79a02..51a3d8b4e 100644 --- a/contrib/unzip/unzip.c +++ b/contrib/unzip/unzip.c @@ -204,7 +204,7 @@ local int unzlocal_getShort (pzlib_filefunc_def,filestream,pX) uLong *pX; { uLong x ; - int i; + int i = 0; int err; err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); @@ -232,7 +232,7 @@ local int unzlocal_getLong (pzlib_filefunc_def,filestream,pX) uLong *pX; { uLong x ; - int i; + int i = 0; int err; err = unzlocal_getByte(pzlib_filefunc_def,filestream,&i); From 9b887153610e6aa8ed0f50eab50aba9673968395 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:32:24 +0200 Subject: [PATCH 38/42] unzip: Bail on bad compression method --- contrib/unzip/unzip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/unzip/unzip.c b/contrib/unzip/unzip.c index 51a3d8b4e..0fac0b29d 100644 --- a/contrib/unzip/unzip.c +++ b/contrib/unzip/unzip.c @@ -1129,7 +1129,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password) if ((s->cur_file_info.compression_method!=0) && (s->cur_file_info.compression_method!=Z_DEFLATED)) - err=UNZ_BADZIPFILE; + return UNZ_BADZIPFILE; pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; pfile_in_zip_read_info->crc32=0; From c248ae37974ed9eb9da0c780ddb54b2022b64e14 Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:33:34 +0200 Subject: [PATCH 39/42] unzip: Remove dead assignments --- contrib/unzip/unzip.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/contrib/unzip/unzip.c b/contrib/unzip/unzip.c index 0fac0b29d..2ab621a6f 100644 --- a/contrib/unzip/unzip.c +++ b/contrib/unzip/unzip.c @@ -733,11 +733,9 @@ local int unzlocal_GetCurrentFileInfoInternal (file, if ((file_info.size_file_comment>0) && (commentBufferSize>0)) if (ZREAD(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) err=UNZ_ERRNO; - lSeek+=file_info.size_file_comment - uSizeRead; } else { - lSeek+=file_info.size_file_comment; } if ((err==UNZ_OK) && (pfile_info!=NULL)) From 76de3e08283afb1c16f1b6cb1af87eeb10aa1edf Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:35:06 +0200 Subject: [PATCH 40/42] clipper: Add assertion to silence a static analyzer warning --- contrib/clipper/clipper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/clipper/clipper.cpp b/contrib/clipper/clipper.cpp index d10cb1e5c..074f22b21 100644 --- a/contrib/clipper/clipper.cpp +++ b/contrib/clipper/clipper.cpp @@ -2431,6 +2431,7 @@ void Clipper::ProcessHorizontal(TEdge *horzEdge) if ( horzEdge->outIdx >= 0 ) IntersectEdges( horzEdge, eMaxPair, IntPoint(horzEdge->xtop, horzEdge->ycurr), ipBoth); + assert(eMaxPair); if (eMaxPair->outIdx >= 0) throw clipperException("ProcessHorizontal error"); DeleteFromAEL(eMaxPair); DeleteFromAEL(horzEdge); From 983e52e308476a115fd410997839b6b0b510611f Mon Sep 17 00:00:00 2001 From: Turo Lamminen Date: Wed, 15 Nov 2017 12:45:27 +0200 Subject: [PATCH 41/42] unzip: Remove dead assignment --- contrib/unzip/unzip.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/contrib/unzip/unzip.c b/contrib/unzip/unzip.c index 2ab621a6f..e8b62e763 100644 --- a/contrib/unzip/unzip.c +++ b/contrib/unzip/unzip.c @@ -725,9 +725,7 @@ local int unzlocal_GetCurrentFileInfoInternal (file, if (lSeek!=0) { - if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) - lSeek=0; - else + if (ZSEEK(s->z_filefunc, s->filestream,lSeek,ZLIB_FILEFUNC_SEEK_CUR)!=0) err=UNZ_ERRNO; } if ((file_info.size_file_comment>0) && (commentBufferSize>0)) From d9965f6220b500b35a2186bebd32b4b49b3e784a Mon Sep 17 00:00:00 2001 From: Giuseppe Barbieri Date: Thu, 16 Nov 2017 14:42:20 +0100 Subject: [PATCH 42/42] Update Importer.cpp --- code/Importer.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/Importer.cpp b/code/Importer.cpp index 379daab02..c6c6f0edd 100644 --- a/code/Importer.cpp +++ b/code/Importer.cpp @@ -274,10 +274,6 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp) if (it != pimpl->mImporter.end()) { pimpl->mImporter.erase(it); - - std::set st; - pImp->GetExtensionList(st); - DefaultLogger::get()->info("Unregistering custom importer: "); return AI_SUCCESS; }