From 435bba30ddf0d99b65904659c3e5d1ec76f70894 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 3 Aug 2020 09:30:02 +0200 Subject: [PATCH 1/3] Move functions into the correct preprocessor branch --- code/Common/DefaultIOStream.cpp | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index 32f47ab07..0c26754f7 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -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, @@ -52,27 +50,32 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. using namespace Assimp; namespace { -template -size_t select_ftell(FILE *file) { - return ::ftell(file); -} - -template -int select_fseek(FILE *file, int64_t offset, int origin) { - return ::fseek(file, static_cast(offset), origin); -} #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) template <> -size_t select_ftell<8>(FILE *file) { +inline size_t select_ftell<8>(FILE *file) { return (size_t)::_ftelli64(file); } template <> -int select_fseek<8>(FILE *file, int64_t offset, int origin) { +inline int select_fseek<8>(FILE *file, int64_t offset, int origin) { return ::_fseeki64(file, offset, origin); } -#endif + +#else + +template +inline size_t select_ftell(FILE *file) { + return ::ftell(file); +} + +template +inline int select_fseek(FILE *file, int64_t offset, int origin) { + return ::fseek(file, static_cast(offset), origin); +} + +#endif // #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) + } // namespace // ---------------------------------------------------------------------------------- From e7ae576614cf7ced16c8d3cd33e893a6ea49636a Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Mon, 3 Aug 2020 15:54:19 +0200 Subject: [PATCH 2/3] undo change --- code/Common/DefaultIOStream.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/code/Common/DefaultIOStream.cpp b/code/Common/DefaultIOStream.cpp index 0c26754f7..449b6c1e1 100644 --- a/code/Common/DefaultIOStream.cpp +++ b/code/Common/DefaultIOStream.cpp @@ -51,6 +51,18 @@ using namespace Assimp; namespace { +template +inline size_t select_ftell(FILE *file) { + return ::ftell(file); +} + +template +inline int select_fseek(FILE *file, int64_t offset, int origin) { + return ::fseek(file, static_cast(offset), origin); +} + + + #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) template <> inline size_t select_ftell<8>(FILE *file) { @@ -62,18 +74,6 @@ inline int select_fseek<8>(FILE *file, int64_t offset, int origin) { return ::_fseeki64(file, offset, origin); } -#else - -template -inline size_t select_ftell(FILE *file) { - return ::ftell(file); -} - -template -inline int select_fseek(FILE *file, int64_t offset, int origin) { - return ::fseek(file, static_cast(offset), origin); -} - #endif // #if defined _WIN32 && (!defined __GNUC__ || __MSVCRT_VERSION__ >= 0x0601) } // namespace From b94183376ced40aecab78b5b5893dca8277542b9 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Wed, 5 Aug 2020 17:56:44 +0200 Subject: [PATCH 3/3] Fix possible overflow in new. --- code/PostProcessing/TriangulateProcess.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/PostProcessing/TriangulateProcess.cpp b/code/PostProcessing/TriangulateProcess.cpp index 8035b34f4..ebd35c997 100644 --- a/code/PostProcessing/TriangulateProcess.cpp +++ b/code/PostProcessing/TriangulateProcess.cpp @@ -64,6 +64,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "Common/PolyTools.h" #include +#include //#define AI_BUILD_TRIANGULATE_COLOR_FACE_WINDING //#define AI_BUILD_TRIANGULATE_DEBUG_POLYS @@ -141,7 +142,7 @@ bool TriangulateProcess::TriangulateMesh( aiMesh* pMesh) } // Find out how many output faces we'll get - unsigned int numOut = 0, max_out = 0; + uint32_t numOut = 0, max_out = 0; bool get_normals = true; for( unsigned int a = 0; a < pMesh->mNumFaces; a++) { aiFace& face = pMesh->mFaces[a];