From ee83c60e1f1a6b7c0247a9865d53462d9ab9f4aa Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 3 Oct 2023 12:23:13 +0200 Subject: [PATCH] Backport https://github.com/nem0/OpenFBX/commit/756d9b28aa01915421a107552655efa68b804fcd --- Source/ThirdParty/OpenFBX/ofbx.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/ThirdParty/OpenFBX/ofbx.cpp b/Source/ThirdParty/OpenFBX/ofbx.cpp index be917dd9c..f3896b5a6 100644 --- a/Source/ThirdParty/OpenFBX/ofbx.cpp +++ b/Source/ThirdParty/OpenFBX/ofbx.cpp @@ -365,6 +365,7 @@ float DataView::toFloat() const bool DataView::operator==(const char* rhs) const { + if (!begin) return false; const char* c = rhs; const char* c2 = (const char*)begin; while (*c && c2 != (const char*)end) @@ -2473,6 +2474,15 @@ static void triangulate( ++in_polygon_idx; if (old_indices[i] < 0) { + if (in_polygon_idx <= 2) { + // invalid polygon, let's pop it + to_old_vertices->pop_back(); + to_old_indices->pop_back(); + if (in_polygon_idx == 2) { + to_old_vertices->pop_back(); + to_old_indices->pop_back(); + } + } in_polygon_idx = 0; } }