From 738c31c3eabb2b35af5d6eeb69b368f1128971e2 Mon Sep 17 00:00:00 2001 From: Krishty Date: Wed, 28 Jul 2021 16:44:46 +0200 Subject: [PATCH 1/3] removed useless code Found while reviewing #3880 --- code/AssetLib/Collada/ColladaParser.cpp | 4 ---- code/AssetLib/X/XFileImporter.cpp | 4 +--- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/code/AssetLib/Collada/ColladaParser.cpp b/code/AssetLib/Collada/ColladaParser.cpp index 37c7274f4..7aa37a112 100644 --- a/code/AssetLib/Collada/ColladaParser.cpp +++ b/code/AssetLib/Collada/ColladaParser.cpp @@ -231,11 +231,7 @@ void ColladaParser::UriDecodePath(aiString &ss) { // Maxon Cinema Collada Export writes "file:///C:\andsoon" with three slashes... // I need to filter it without destroying linux paths starting with "/somewhere" -#if defined(_MSC_VER) if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') { -#else - if (ss.data[0] == '/' && isalpha((unsigned char)ss.data[1]) && ss.data[2] == ':') { -#endif --ss.length; ::memmove(ss.data, ss.data + 1, ss.length); ss.data[ss.length] = 0; diff --git a/code/AssetLib/X/XFileImporter.cpp b/code/AssetLib/X/XFileImporter.cpp index df1aba331..4c8c54551 100644 --- a/code/AssetLib/X/XFileImporter.cpp +++ b/code/AssetLib/X/XFileImporter.cpp @@ -667,9 +667,7 @@ void XFileImporter::ConvertMaterials( aiScene* pScene, std::vector Date: Thu, 29 Jul 2021 14:57:25 +0200 Subject: [PATCH 2/3] more range-based for f6b4370f6ac1bf2db0ef9edeb0ff1ce8c7e61aab and 7c822f23bd075d3621d2e2f33188e1659f657b31 introduced raw loops on data types with heavy nesting; range-based for suits better here --- code/AssetLib/glTF2/glTF2Importer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index d80df97d2..921aaad9e 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -992,8 +992,8 @@ void ParseExtensions(aiMetadata *metadata, const CustomExtension &extension) { metadata->Add(extension.name.c_str(), extension.mBoolValue.value); } else if (extension.mValues.isPresent) { aiMetadata val; - for (size_t i = 0; i < extension.mValues.value.size(); ++i) { - ParseExtensions(&val, extension.mValues.value[i]); + for (auto const & subExtension : extension.mValues.value) { + ParseExtensions(&val, subExtension); } metadata->Add(extension.name.c_str(), val); } @@ -1001,8 +1001,8 @@ void ParseExtensions(aiMetadata *metadata, const CustomExtension &extension) { void ParseExtras(aiMetadata *metadata, const CustomExtension &extension) { if (extension.mValues.isPresent) { - for (size_t i = 0; i < extension.mValues.value.size(); ++i) { - ParseExtensions(metadata, extension.mValues.value[i]); + for (auto const & subExtension : extension.mValues.value) { + ParseExtensions(metadata, subExtension); } } } From 538cb3125c6d83a0a4d76ec589e21a787093a2f0 Mon Sep 17 00:00:00 2001 From: Hill Ma Date: Mon, 2 Aug 2021 11:47:35 -0700 Subject: [PATCH 3/3] Use strlen() rather than fixed length in fast_atof.h This avoids reading past the length of the input string. --- include/assimp/fast_atof.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/assimp/fast_atof.h b/include/assimp/fast_atof.h index aea793f35..43bbbff64 100644 --- a/include/assimp/fast_atof.h +++ b/include/assimp/fast_atof.h @@ -194,7 +194,7 @@ uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_ino if ( *in < '0' || *in > '9' ) { // The string is known to be bad, so don't risk printing the whole thing. - throw ExceptionType("The string \"", ai_str_toprintable(in, 30), "\" cannot be converted into a value." ); + throw ExceptionType("The string \"", ai_str_toprintable(in, (int)strlen(in)), "\" cannot be converted into a value." ); } for ( ;; ) { @@ -294,7 +294,7 @@ const char* fast_atoreal_move(const char* c, Real& out, bool check_comma = true) if (!(c[0] >= '0' && c[0] <= '9') && !((c[0] == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')) { // The string is known to be bad, so don't risk printing the whole thing. - throw ExceptionType("Cannot parse string \"", ai_str_toprintable(c, 30), + throw ExceptionType("Cannot parse string \"", ai_str_toprintable(c, (int)strlen(c)), "\" as a real number: does not start with digit " "or decimal point followed by digit."); }