From d49aed4585c0f064963e126165ae5b434d118de3 Mon Sep 17 00:00:00 2001 From: Max Vollmer Date: Mon, 11 Jan 2021 08:45:47 +0000 Subject: [PATCH 01/20] * Check that buffer view has buffer * Handle integer overflow when calculating byte length * Minor code cleanup for exception messages --- code/AssetLib/glTF2/glTF2Asset.inl | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/code/AssetLib/glTF2/glTF2Asset.inl b/code/AssetLib/glTF2/glTF2Asset.inl index 456da9772..0e265efef 100644 --- a/code/AssetLib/glTF2/glTF2Asset.inl +++ b/code/AssetLib/glTF2/glTF2Asset.inl @@ -560,18 +560,17 @@ inline void BufferView::Read(Value &obj, Asset &r) { buffer = r.buffers.Retrieve(bufferVal->GetUint()); } + if (!buffer) { + throw DeadlyImportError("GLTF: Buffer view without valid buffer."); + } + byteOffset = MemberOrDefault(obj, "byteOffset", size_t(0)); byteLength = MemberOrDefault(obj, "byteLength", size_t(0)); byteStride = MemberOrDefault(obj, "byteStride", 0u); // Check length if ((byteOffset + byteLength) > buffer->byteLength) { - const uint8_t val_size = 64; - - char val[val_size]; - - ai_snprintf(val, val_size, "%llu, %llu", (unsigned long long)byteOffset, (unsigned long long)byteLength); - throw DeadlyImportError("GLTF: Buffer view with offset/length (", val, ") is out of range."); + throw DeadlyImportError("GLTF: Buffer view with offset/length (", byteOffset, "/", byteLength, ") is out of range."); } } @@ -649,13 +648,14 @@ inline void Accessor::Read(Value &obj, Asset &r) { if (bufferView) { // Check length unsigned long long byteLength = (unsigned long long)GetBytesPerComponent() * (unsigned long long)count; + + // handle integer overflow + if (byteLength < count) { + throw DeadlyImportError("GLTF: Accessor with offset/count (", byteOffset, "/", count, ") is out of range."); + } + if ((byteOffset + byteLength) > bufferView->byteLength || (bufferView->byteOffset + byteOffset + byteLength) > bufferView->buffer->byteLength) { - const uint8_t val_size = 64; - - char val[val_size]; - - ai_snprintf(val, val_size, "%llu, %llu", (unsigned long long)byteOffset, (unsigned long long)byteLength); - throw DeadlyImportError("GLTF: Accessor with offset/length (", val, ") is out of range."); + throw DeadlyImportError("GLTF: Accessor with offset/length (", byteOffset, "/", byteLength, ") is out of range."); } } From 0c2772e8bf7a1c2b93f486634695ec820dffdf91 Mon Sep 17 00:00:00 2001 From: Kirill Gavrilov Date: Tue, 12 Jan 2021 01:00:45 +0300 Subject: [PATCH 02/20] aiMaterial::GetTexture() - fix misleading description of path argument. Mention aiScene::GetEmbeddedTexture() as a proper way to check if returned path points to a file or to embedded texture. --- include/assimp/material.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/assimp/material.h b/include/assimp/material.h index 4daf0cdeb..13529f172 100644 --- a/include/assimp/material.h +++ b/include/assimp/material.h @@ -735,9 +735,9 @@ public: * #GetTextureCount() can be used to determine the number of textures * per texture type. * @param path Receives the path to the texture. - * If the texture is embedded, receives a '*' followed by the id of - * the texture (for the textures stored in the corresponding scene) which - * can be converted to an int using a function like atoi. + * Use aiScene::GetEmbeddedTexture() method to determine if returned path + * is an image file to be opened or a string key of embedded texture stored in the corresponding scene + * (could be a '*' followed by the id of the texture in case of no name) * NULL is a valid value. * @param mapping The texture mapping. * NULL is allowed as value. 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 03/20] 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 04/20] 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 484ac21ef5e772b96186f3b57d19cacf19d3ebba Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Thu, 14 Jan 2021 11:53:25 +0100 Subject: [PATCH 05/20] Remove dependency to posix-extension function --- include/assimp/StringComparison.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/include/assimp/StringComparison.h b/include/assimp/StringComparison.h index 255123c0e..21007bf68 100644 --- a/include/assimp/StringComparison.h +++ b/include/assimp/StringComparison.h @@ -145,11 +145,7 @@ int ASSIMP_stricmp(const char *s1, const char *s2) { #if (defined _MSC_VER) return ::_stricmp(s1, s2); -#elif defined(__GNUC__) - - return ::strcasecmp(s1, s2); #else - char c1, c2; do { c1 = tolower(*s1++); From 6db343386b73d69e0e4c14ab0bde0edab5e1585f Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Fri, 15 Jan 2021 16:46:15 +0100 Subject: [PATCH 06/20] remove install of zlibstatic --- contrib/zlib/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/zlib/CMakeLists.txt b/contrib/zlib/CMakeLists.txt index 0e8a4b1e1..f088646a7 100644 --- a/contrib/zlib/CMakeLists.txt +++ b/contrib/zlib/CMakeLists.txt @@ -198,11 +198,11 @@ endif(MINGW) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -IF(WIN32) - INSTALL( TARGETS zlibstatic - EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} - RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} - COMPONENT ${LIBASSIMP_COMPONENT}) -ENDIF() +#IF(WIN32) +# INSTALL( TARGETS zlibstatic +# EXPORT "${TARGETS_EXPORT_NAME}" +# LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} +# ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} +# RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} +# COMPONENT ${LIBASSIMP_COMPONENT}) +#ENDIF() From 8ad2661e0c85c80051992beee84c4c69c2ab1836 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 16 Jan 2021 12:00:42 +0100 Subject: [PATCH 07/20] Update CMakeLists.txt --- contrib/zlib/CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/contrib/zlib/CMakeLists.txt b/contrib/zlib/CMakeLists.txt index f088646a7..0e8a4b1e1 100644 --- a/contrib/zlib/CMakeLists.txt +++ b/contrib/zlib/CMakeLists.txt @@ -198,11 +198,11 @@ endif(MINGW) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -#IF(WIN32) -# INSTALL( TARGETS zlibstatic -# EXPORT "${TARGETS_EXPORT_NAME}" -# LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} -# ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} -# RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} -# COMPONENT ${LIBASSIMP_COMPONENT}) -#ENDIF() +IF(WIN32) + INSTALL( TARGETS zlibstatic + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} + RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} + COMPONENT ${LIBASSIMP_COMPONENT}) +ENDIF() From 9334e076195635634adceeafdee68573e7c923d9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 16 Jan 2021 16:14:49 +0100 Subject: [PATCH 08/20] Update CMakeLists.txt --- contrib/zlib/CMakeLists.txt | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/contrib/zlib/CMakeLists.txt b/contrib/zlib/CMakeLists.txt index 0e8a4b1e1..469151ff6 100644 --- a/contrib/zlib/CMakeLists.txt +++ b/contrib/zlib/CMakeLists.txt @@ -198,11 +198,9 @@ endif(MINGW) add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) -IF(WIN32) - INSTALL( TARGETS zlibstatic - EXPORT "${TARGETS_EXPORT_NAME}" - LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} - ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} - RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} - COMPONENT ${LIBASSIMP_COMPONENT}) -ENDIF() +INSTALL( TARGETS zlibstatic + EXPORT "${TARGETS_EXPORT_NAME}" + LIBRARY DESTINATION ${ASSIMP_LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${ASSIMP_LIB_INSTALL_DIR} + RUNTIME DESTINATION ${ASSIMP_BIN_INSTALL_DIR} + COMPONENT ${LIBASSIMP_COMPONENT}) From 0969bf350064ca00f54cb0dd83f54688f22897a2 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 17 Jan 2021 20:39:19 +0100 Subject: [PATCH 09/20] Fix Divide-by-zero in vector3 Fix for https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29655 --- include/assimp/vector3.inl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/assimp/vector3.inl b/include/assimp/vector3.inl index 2765115a2..fda47d6a7 100644 --- a/include/assimp/vector3.inl +++ b/include/assimp/vector3.inl @@ -154,6 +154,9 @@ const aiVector3t& aiVector3t::operator *= (TReal f) { template AI_FORCE_INLINE const aiVector3t& aiVector3t::operator /= (TReal f) { + if ((T) f==0.0) { + return *this; + } const TReal invF = (TReal) 1.0 / f; x *= invF; y *= invF; From 658fec3e61cdb5c2eed66b1d6d3747b85d97565d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sun, 17 Jan 2021 20:41:44 +0100 Subject: [PATCH 10/20] Fix cast --- include/assimp/vector3.inl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/assimp/vector3.inl b/include/assimp/vector3.inl index fda47d6a7..1d024e03f 100644 --- a/include/assimp/vector3.inl +++ b/include/assimp/vector3.inl @@ -5,8 +5,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -154,7 +152,7 @@ const aiVector3t& aiVector3t::operator *= (TReal f) { template AI_FORCE_INLINE const aiVector3t& aiVector3t::operator /= (TReal f) { - if ((T) f==0.0) { + if ( f == static_cast(0.0)) { return *this; } const TReal invF = (TReal) 1.0 / f; From 5a764fff042cd21756681bd08fe3afc172e3e070 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Jan 2021 19:44:10 +0100 Subject: [PATCH 11/20] Fix overflow in aiString --- include/assimp/types.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index 74763d496..0e50ed0ae 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -307,7 +307,7 @@ struct aiString { void Set(const char *sz) { const ai_int32 len = (ai_uint32)::strlen(sz); if (len > (ai_int32)MAXLEN - 1) { - return; + len = (ai_int32) MAXLEN - 1; } length = len; memcpy(data, sz, len); @@ -321,7 +321,10 @@ struct aiString { } length = rOther.length; - ; + if (length >(MAXLEN - 1)) { + length = (ai_int32) MAXLEN - 1; + } + memcpy(data, rOther.data, length); data[length] = '\0'; return *this; From 11ee9d367321ea175f9f2917a26db9f7b7e66ef3 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Jan 2021 19:46:32 +0100 Subject: [PATCH 12/20] Update types.h --- include/assimp/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/assimp/types.h b/include/assimp/types.h index 0e50ed0ae..99527dcc2 100644 --- a/include/assimp/types.h +++ b/include/assimp/types.h @@ -305,7 +305,7 @@ struct aiString { /** Copy a const char* to the aiString */ void Set(const char *sz) { - const ai_int32 len = (ai_uint32)::strlen(sz); + ai_int32 len = (ai_uint32)::strlen(sz); if (len > (ai_int32)MAXLEN - 1) { len = (ai_int32) MAXLEN - 1; } From 0803e5e6f3fb210c7e0bb035b611eb595e70cabf Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Jan 2021 20:25:33 +0100 Subject: [PATCH 13/20] Fix nullptr dereference in scenepreprocessor --- code/Common/ScenePreprocessor.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/code/Common/ScenePreprocessor.cpp b/code/Common/ScenePreprocessor.cpp index 2b73d9452..31d0ab75f 100644 --- a/code/Common/ScenePreprocessor.cpp +++ b/code/Common/ScenePreprocessor.cpp @@ -4,7 +4,6 @@ Open Asset Import Library (assimp) Copyright (c) 2006-2020, assimp team - All rights reserved. Redistribution and use of this software in source and binary forms, @@ -52,8 +51,12 @@ void ScenePreprocessor::ProcessScene() { ai_assert(scene != nullptr); // Process all meshes - for (unsigned int i = 0; i < scene->mNumMeshes; ++i) + for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { + if (nullptr == scene->mMeshes[i] { + continue; + } ProcessMesh(scene->mMeshes[i]); + } // - nothing to do for nodes for the moment // - nothing to do for textures for the moment @@ -61,8 +64,12 @@ void ScenePreprocessor::ProcessScene() { // - nothing to do for cameras for the moment // Process all animations - for (unsigned int i = 0; i < scene->mNumAnimations; ++i) + for (unsigned int i = 0; i < scene->mNumAnimations; ++i) { + if (nullptr == scene->mAnimations[i]) { + continue; + } ProcessAnimation(scene->mAnimations[i]); + } // Generate a default material if none was specified if (!scene->mNumMaterials && scene->mNumMeshes) { From f24c04292506325fe3aba355d350d5f58812622e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 18 Jan 2021 20:28:38 +0100 Subject: [PATCH 14/20] Fix typo --- code/Common/ScenePreprocessor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Common/ScenePreprocessor.cpp b/code/Common/ScenePreprocessor.cpp index 31d0ab75f..113ca7ff1 100644 --- a/code/Common/ScenePreprocessor.cpp +++ b/code/Common/ScenePreprocessor.cpp @@ -52,7 +52,7 @@ void ScenePreprocessor::ProcessScene() { // Process all meshes for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { - if (nullptr == scene->mMeshes[i] { + if (nullptr == scene->mMeshes[i]) { continue; } ProcessMesh(scene->mMeshes[i]); From 0bc5cf9fd334dd50b0389b8575bb3a0f0b35bac7 Mon Sep 17 00:00:00 2001 From: Dan Church Date: Mon, 18 Jan 2021 15:23:05 -0600 Subject: [PATCH 15/20] 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 16/20] 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 17/20] 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 18/20] 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 19/20] 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 20/20] 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