From c15d44e855270e7fd8241b54cf7c00ac3b467b57 Mon Sep 17 00:00:00 2001 From: jonnxie Date: Tue, 22 Mar 2022 10:59:03 +0800 Subject: [PATCH] Fixed loadNode function memory leak bug. --- base/VulkanglTFModel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/base/VulkanglTFModel.cpp b/base/VulkanglTFModel.cpp index a4b5978c..1fa57777 100644 --- a/base/VulkanglTFModel.cpp +++ b/base/VulkanglTFModel.cpp @@ -906,6 +906,7 @@ void vkglTF::Model::loadNode(vkglTF::Node *parent, const tinygltf::Node &node, u for (size_t index = 0; index < accessor.count; index++) { indexBuffer.push_back(buf[index] + vertexStart); } + delete[] buf; break; } case TINYGLTF_PARAMETER_TYPE_UNSIGNED_SHORT: { @@ -914,7 +915,8 @@ void vkglTF::Model::loadNode(vkglTF::Node *parent, const tinygltf::Node &node, u for (size_t index = 0; index < accessor.count; index++) { indexBuffer.push_back(buf[index] + vertexStart); } - break; + delete[] buf; + break; } case TINYGLTF_PARAMETER_TYPE_UNSIGNED_BYTE: { uint8_t *buf = new uint8_t[accessor.count]; @@ -922,7 +924,8 @@ void vkglTF::Model::loadNode(vkglTF::Node *parent, const tinygltf::Node &node, u for (size_t index = 0; index < accessor.count; index++) { indexBuffer.push_back(buf[index] + vertexStart); } - break; + delete[] buf; + break; } default: std::cerr << "Index component type " << accessor.componentType << " not supported!" << std::endl;