diff --git a/code/Assbin/AssbinExporter.cpp b/code/Assbin/AssbinExporter.cpp index aa0c246be..86a42c400 100644 --- a/code/Assbin/AssbinExporter.cpp +++ b/code/Assbin/AssbinExporter.cpp @@ -413,7 +413,8 @@ protected: Write(&chunk,tex->mWidth); Write(&chunk,tex->mHeight); - chunk.Write( tex->achFormatHint, sizeof(char), 4 ); + // Write the texture format, but don't include the null terminator. + chunk.Write( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 ); if(!shortened) { if (!tex->mHeight) { diff --git a/code/Assbin/AssbinLoader.cpp b/code/Assbin/AssbinLoader.cpp index 8a9751018..71e35cb6a 100644 --- a/code/Assbin/AssbinLoader.cpp +++ b/code/Assbin/AssbinLoader.cpp @@ -535,7 +535,7 @@ void AssbinImporter::ReadBinaryTexture(IOStream * stream, aiTexture* tex) { tex->mWidth = Read(stream); tex->mHeight = Read(stream); - stream->Read( tex->achFormatHint, sizeof(char), 4 ); + stream->Read( tex->achFormatHint, sizeof(char), HINTMAXTEXTURELEN - 1 ); if(!shortened) { if (!tex->mHeight) { diff --git a/code/PostProcessing/ValidateDataStructure.cpp b/code/PostProcessing/ValidateDataStructure.cpp index 36c33b29c..a812efb0b 100644 --- a/code/PostProcessing/ValidateDataStructure.cpp +++ b/code/PostProcessing/ValidateDataStructure.cpp @@ -798,7 +798,7 @@ void ValidateDSProcess::Validate( const aiTexture* pTexture) if (!pTexture->mWidth) { ReportError("aiTexture::mWidth is zero (compressed texture)"); } - if ('\0' != pTexture->achFormatHint[3]) { + if ('\0' != pTexture->achFormatHint[HINTMAXTEXTURELEN - 1]) { ReportWarning("aiTexture::achFormatHint must be zero-terminated"); } else if ('.' == pTexture->achFormatHint[0]) { diff --git a/include/assimp/texture.h b/include/assimp/texture.h index 274185a30..5a4486431 100644 --- a/include/assimp/texture.h +++ b/include/assimp/texture.h @@ -207,8 +207,7 @@ struct aiTexture { , mHeight(0) , pcData(nullptr) , mFilename() { - achFormatHint[0] = achFormatHint[1] = 0; - achFormatHint[2] = achFormatHint[3] = 0; + memset(achFormatHint, 0, sizeof(achFormatHint)); } // Destruction diff --git a/tools/assimp_cmd/CompareDump.cpp b/tools/assimp_cmd/CompareDump.cpp index 3250c528a..86a9cfe4c 100644 --- a/tools/assimp_cmd/CompareDump.cpp +++ b/tools/assimp_cmd/CompareDump.cpp @@ -800,6 +800,10 @@ void CompareOnTheFlyTexture(comparer_context& comp) { comp.cmp("achFormatHint[1]"); comp.cmp("achFormatHint[2]"); comp.cmp("achFormatHint[3]"); + comp.cmp("achFormatHint[4]"); + comp.cmp("achFormatHint[5]"); + comp.cmp("achFormatHint[6]"); + comp.cmp("achFormatHint[7]"); } //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/tools/assimp_cmd/WriteDumb.cpp b/tools/assimp_cmd/WriteDumb.cpp index 5b5dfd2a1..b4c22a439 100644 --- a/tools/assimp_cmd/WriteDumb.cpp +++ b/tools/assimp_cmd/WriteDumb.cpp @@ -312,7 +312,8 @@ uint32_t WriteBinaryTexture(const aiTexture* tex) len += Write(tex->mWidth); len += Write(tex->mHeight); - len += static_cast(fwrite(tex->achFormatHint,1,4,out)); + // Write the texture format, but don't include the null terminator. + len += static_cast(fwrite(tex->achFormatHint,sizeof(char),HINTMAXTEXTURELEN - 1,out)); if(!shortened) { if (!tex->mHeight) {