From 2d372b302ffdaeb7ac629ca105b8a13e6de584e8 Mon Sep 17 00:00:00 2001 From: Umesh Rajesh Ramchandani Date: Fri, 2 Dec 2022 13:59:08 +0100 Subject: [PATCH] Fixed bug when exporting binary FBX Fixed vector subscript out of range bug when NULL_RECORD is passed to PutString and is actually null --- code/AssetLib/FBX/FBXCommon.h | 1 + code/AssetLib/FBX/FBXExportNode.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/code/AssetLib/FBX/FBXCommon.h b/code/AssetLib/FBX/FBXCommon.h index c592c5649..c3d715892 100644 --- a/code/AssetLib/FBX/FBXCommon.h +++ b/code/AssetLib/FBX/FBXCommon.h @@ -55,6 +55,7 @@ const char NULL_RECORD[NumNullRecords] = { // 25 null bytes in 64-bit and 13 nul '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' }; // who knows why, it looks like two integers 32/64 bit (compressed and uncompressed sizes?) + 1 byte (might be compression type?) +static std::string NULL_RECORD_STRING(NumNullRecords, '\0'); const std::string SEPARATOR = { '\x00', '\x01' }; // for use inside strings const std::string MAGIC_NODE_TAG = "_$AssimpFbx$"; // from import const int64_t SECOND = 46186158000; // FBX's kTime unit diff --git a/code/AssetLib/FBX/FBXExportNode.cpp b/code/AssetLib/FBX/FBXExportNode.cpp index 21c61b257..21e591425 100644 --- a/code/AssetLib/FBX/FBXExportNode.cpp +++ b/code/AssetLib/FBX/FBXExportNode.cpp @@ -360,7 +360,7 @@ void FBX::Node::EndBinary( bool has_children ) { // if there were children, add a null record - if (has_children) { s.PutString(Assimp::FBX::NULL_RECORD); } + if (has_children) { s.PutString(Assimp::FBX::NULL_RECORD_STRING); } // now go back and write initial pos this->end_pos = s.Tell();