From 9f3a7e95ab2732602fb68dfd2bdd5ed976ceb5d0 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 23 Dec 2024 12:23:42 +0100 Subject: [PATCH] Fix: Fix name collision (#5937) * Fix: Fix name collision * Fix: Fix possible override * Fix: Use reentrant providing time function * Fix: Fix override * Update AssbinFileWriter.cpp Revert, not portable. * Update AssxmlFileWriter.cpp Revert asctime_r, not portable. --- code/AssetLib/AMF/AMFImporter_Geometry.cpp | 2 +- code/AssetLib/AMF/AMFImporter_Node.hpp | 2 +- code/AssetLib/Assxml/AssxmlFileWriter.cpp | 4 +--- code/AssetLib/glTF/glTFImporter.cpp | 9 ++++----- code/AssetLib/glTF2/glTF2Importer.cpp | 8 ++++---- 5 files changed, 11 insertions(+), 14 deletions(-) diff --git a/code/AssetLib/AMF/AMFImporter_Geometry.cpp b/code/AssetLib/AMF/AMFImporter_Geometry.cpp index b1d87eb2e..0a5dbae4e 100644 --- a/code/AssetLib/AMF/AMFImporter_Geometry.cpp +++ b/code/AssetLib/AMF/AMFImporter_Geometry.cpp @@ -202,7 +202,7 @@ void AMFImporter::ParseNode_Volume(XmlNode &node) { ((AMFVolume *)ne)->MaterialID = node.attribute("materialid").as_string(); - ((AMFVolume *)ne)->Type = type; + ((AMFVolume *)ne)->VolumeType = type; // Check for child nodes bool col_read = false; if (!node.empty()) { diff --git a/code/AssetLib/AMF/AMFImporter_Node.hpp b/code/AssetLib/AMF/AMFImporter_Node.hpp index 2b4f6717d..a152f5d66 100644 --- a/code/AssetLib/AMF/AMFImporter_Node.hpp +++ b/code/AssetLib/AMF/AMFImporter_Node.hpp @@ -225,7 +225,7 @@ struct AMFVertices : public AMFNodeElementBase { /// Structure that define volume node. struct AMFVolume : public AMFNodeElementBase { std::string MaterialID; ///< Which material to use. - std::string Type; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed. + std::string VolumeType; ///< What this volume describes can be "region" or "support". If none specified, "object" is assumed. /// Constructor. /// \param [in] pParent - pointer to parent node. diff --git a/code/AssetLib/Assxml/AssxmlFileWriter.cpp b/code/AssetLib/Assxml/AssxmlFileWriter.cpp index f6fdc4a0c..e9f6bf83e 100644 --- a/code/AssetLib/Assxml/AssxmlFileWriter.cpp +++ b/code/AssetLib/Assxml/AssxmlFileWriter.cpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2024, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -36,7 +35,6 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - ---------------------------------------------------------------------- */ @@ -223,7 +221,7 @@ static void WriteDump(const char *pFile, const char *cmd, const aiScene *scene, const unsigned int majorVersion(aiGetVersionMajor()); const unsigned int minorVersion(aiGetVersionMinor()); const unsigned int rev(aiGetVersionRevision()); - const char *curtime(asctime(p)); + const char *curtime = asctime(p); ioprintf(io, header.c_str(), majorVersion, minorVersion, rev, pFile, c.c_str(), curtime, scene->mFlags, 0u); // write the node graph diff --git a/code/AssetLib/glTF/glTFImporter.cpp b/code/AssetLib/glTF/glTFImporter.cpp index 91f39e92b..dc6339c54 100644 --- a/code/AssetLib/glTF/glTFImporter.cpp +++ b/code/AssetLib/glTF/glTFImporter.cpp @@ -661,11 +661,10 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset &r) { if (strncmp(ext, "jpeg", 4) == 0) { ext = "jpg"; } - - const size_t len = strlen(ext); - if (len <= 3) { - strncpy(tex->achFormatHint, ext, len); - } + tex->achFormatHint[3] = '\0'; + size_t len = strlen(ext); + if (len > 3) len = 3; + memcpy(tex->achFormatHint, ext, len); } } } diff --git a/code/AssetLib/glTF2/glTF2Importer.cpp b/code/AssetLib/glTF2/glTF2Importer.cpp index 008c0b53d..2571f6367 100644 --- a/code/AssetLib/glTF2/glTF2Importer.cpp +++ b/code/AssetLib/glTF2/glTF2Importer.cpp @@ -1638,10 +1638,10 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) { ext = "bu"; } - const size_t len = strlen(ext); - if (len <= 3) { - strncpy(tex->achFormatHint, ext, len); - } + size_t len = strlen(ext); + if (len > 3) len = 3; + tex->achFormatHint[3] = '\0'; + memcpy(tex->achFormatHint, ext, len); } } }