From 0216a02ed451b55232b35d0dff3953a7c20fb18f Mon Sep 17 00:00:00 2001 From: Josiah VanderZee Date: Mon, 14 Nov 2022 19:34:36 -0600 Subject: [PATCH] Fix segfault from reading bad number of indices --- source/Irrlicht/CGLTFMeshFileLoader.cpp | 2 +- source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Irrlicht/CGLTFMeshFileLoader.cpp b/source/Irrlicht/CGLTFMeshFileLoader.cpp index 3e0ee23d..5ee1d951 100644 --- a/source/Irrlicht/CGLTFMeshFileLoader.cpp +++ b/source/Irrlicht/CGLTFMeshFileLoader.cpp @@ -194,7 +194,7 @@ static u16* getIndices(const tinygltf::Model& model, const auto& indicesBuffer = model.buffers[view.buffer]; return readIndices( BufferOffset(indicesBuffer.data, view.byteOffset), - model.accessors[0].count); + model.accessors[accessorId].count); } CGLTFMeshFileLoader::CGLTFMeshFileLoader() diff --git a/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp b/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp index 754cfd8d..21d62634 100644 --- a/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp +++ b/source/Irrlicht/tests/testCGLTFMeshFileLoader.cpp @@ -91,6 +91,7 @@ TEST_CASE("blender cube") { CHECK(indices[0] == 0); CHECK(indices[1] == 3); CHECK(indices[2] == 9); + CHECK(indices[35] == 16); } SECTION("vertex normals are correct") {