From 2e96366d045fcdf1a0feb0e1f0d67509274fc506 Mon Sep 17 00:00:00 2001 From: ihsinme <61293369+ihsinme@users.noreply.github.com> Date: Tue, 12 Jan 2021 15:40:19 +0300 Subject: [PATCH 1/8] Update AMFImporter_Geometry.cpp --- code/AssetLib/AMF/AMFImporter_Geometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/AssetLib/AMF/AMFImporter_Geometry.cpp b/code/AssetLib/AMF/AMFImporter_Geometry.cpp index 6a9ccc1aa..7afe52311 100644 --- a/code/AssetLib/AMF/AMFImporter_Geometry.cpp +++ b/code/AssetLib/AMF/AMFImporter_Geometry.cpp @@ -61,12 +61,12 @@ namespace Assimp { void AMFImporter::ParseNode_Mesh(XmlNode &node) { AMFNodeElementBase *ne = nullptr; - // create new mesh object. - ne = new AMFMesh(mNodeElement_Cur); // Check for child nodes if (0 != ASSIMP_stricmp(node.name(), "mesh")) { return; } + // create new mesh object. + ne = new AMFMesh(mNodeElement_Cur); bool found_verts = false, found_volumes = false; if (!node.empty()) { ParseHelper_Node_Enter(ne); From 070072370d24bd0f74791fb53ebf7395f4a20a8b Mon Sep 17 00:00:00 2001 From: ihsinme <61293369+ihsinme@users.noreply.github.com> Date: Tue, 12 Jan 2021 15:43:40 +0300 Subject: [PATCH 2/8] Update AMFImporter_Material.cpp --- code/AssetLib/AMF/AMFImporter_Material.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/code/AssetLib/AMF/AMFImporter_Material.cpp b/code/AssetLib/AMF/AMFImporter_Material.cpp index 05ed00848..e1b6c3e8b 100644 --- a/code/AssetLib/AMF/AMFImporter_Material.cpp +++ b/code/AssetLib/AMF/AMFImporter_Material.cpp @@ -165,15 +165,15 @@ void AMFImporter::ParseNode_Texture(XmlNode &node) { std::string type = node.attribute("type").as_string(); bool tiled = node.attribute("tiled").as_bool(); - // create new texture object. - AMFNodeElementBase *ne = new AMFTexture(mNodeElement_Cur); - - AMFTexture& als = *((AMFTexture*)ne);// alias for convenience - if (node.empty()) { return; } + // create new texture object. + AMFNodeElementBase *ne = new AMFTexture(mNodeElement_Cur); + + AMFTexture& als = *((AMFTexture*)ne);// alias for convenience + std::string enc64_data = node.value(); // Check for child nodes From 0bc5cf9fd334dd50b0389b8575bb3a0f0b35bac7 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 18 Jan 2021 15:23:05 -0600 Subject: [PATCH 3/8] Fix build failure on Linux --- code/Common/ZipArchiveIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/ZipArchiveIOSystem.cpp b/code/Common/ZipArchiveIOSystem.cpp index 870dd702d..e0c9ebd7a 100644 --- a/code/Common/ZipArchiveIOSystem.cpp +++ b/code/Common/ZipArchiveIOSystem.cpp @@ -152,7 +152,7 @@ zlib_filefunc_def IOSystem2Unzip::get(IOSystem *pIOHandler) { mapping.ztell_file = (tell_file_func)tell; mapping.zseek_file = (seek_file_func)seek; mapping.zclose_file = (close_file_func)close; - mapping.zerror_file = (error_file_func)testerror; + mapping.zerror_file = testerror; mapping.opaque = reinterpret_cast(pIOHandler); From 5a6498af92292b2226bcbdc9e5d20cdd71819d20 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Jan 2021 21:14:38 +0100 Subject: [PATCH 4/8] Fix nullptr access --- code/Common/DefaultIOSystem.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index 2512e57c8..39f2405f6 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -60,19 +60,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; #ifdef _WIN32 + +const std::wstring wdummy; + static std::wstring Utf8ToWide(const char *in) { + if (nullptr == in) { + return wdummy; + } int size = MultiByteToWideChar(CP_UTF8, 0, in, -1, nullptr, 0); // size includes terminating null; std::wstring adds null automatically std::wstring out(static_cast(size) - 1, L'\0'); MultiByteToWideChar(CP_UTF8, 0, in, -1, &out[0], size); + return out; } +const std::wstring dummy; + static std::string WideToUtf8(const wchar_t *in) { + if (nullptr == in) { + return dummy; + } int size = WideCharToMultiByte(CP_UTF8, 0, in, -1, nullptr, 0, nullptr, nullptr); // size includes terminating null; std::string adds null automatically std::string out(static_cast(size) - 1, '\0'); WideCharToMultiByte(CP_UTF8, 0, in, -1, &out[0], size, nullptr, nullptr); + return out; } #endif @@ -104,7 +117,12 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { ai_assert(strMode != nullptr); FILE *file; #ifdef _WIN32 - file = ::_wfopen(Utf8ToWide(strFile).c_str(), Utf8ToWide(strMode).c_str()); + std::string name = Utf8ToWide(strFile).c_str(); + if (name.empty()) { + return nullptr; + } + + file = ::_wfopen(, Utf8ToWide(strMode).c_str()); #else file = ::fopen(strFile, strMode); #endif From 5b325af79f7813631fce81f2173e3e9c69fa7618 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Jan 2021 21:19:42 +0100 Subject: [PATCH 5/8] Fix typo. --- code/Common/DefaultIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index 39f2405f6..c3059ac31 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -75,7 +75,7 @@ static std::wstring Utf8ToWide(const char *in) { return out; } -const std::wstring dummy; +const std::string dummy; static std::string WideToUtf8(const wchar_t *in) { if (nullptr == in) { From f05a57560baa19f8ff49e9d9ddcf5fd1cc693d11 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Jan 2021 21:27:50 +0100 Subject: [PATCH 6/8] Remove buggy method. --- code/Common/DefaultIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index c3059ac31..82029f0c9 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -117,7 +117,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { ai_assert(strMode != nullptr); FILE *file; #ifdef _WIN32 - std::string name = Utf8ToWide(strFile).c_str(); + std::string name = Utf8ToWide(strFile); if (name.empty()) { return nullptr; } From ed3e7457529cd29ed8c4c6bb5b56d37349d5a371 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 19 Jan 2021 21:58:04 +0100 Subject: [PATCH 7/8] Update DefaultIOSystem.cpp --- code/Common/DefaultIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index 82029f0c9..52af14b37 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -117,7 +117,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { ai_assert(strMode != nullptr); FILE *file; #ifdef _WIN32 - std::string name = Utf8ToWide(strFile); + std::wstring name = Utf8ToWide(strFile); if (name.empty()) { return nullptr; } From f8dd3a9aa6b5104d94070ca5341484b35ac3c7c1 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 20 Jan 2021 08:05:43 +0100 Subject: [PATCH 8/8] Update DefaultIOSystem.cpp --- code/Common/DefaultIOSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/DefaultIOSystem.cpp b/code/Common/DefaultIOSystem.cpp index 52af14b37..4154aad32 100644 --- a/code/Common/DefaultIOSystem.cpp +++ b/code/Common/DefaultIOSystem.cpp @@ -122,7 +122,7 @@ IOStream *DefaultIOSystem::Open(const char *strFile, const char *strMode) { return nullptr; } - file = ::_wfopen(, Utf8ToWide(strMode).c_str()); + file = ::_wfopen(name.c_str(), Utf8ToWide(strMode).c_str()); #else file = ::fopen(strFile, strMode); #endif