From 14c70d308299dbdc176536a001611615bfd62924 Mon Sep 17 00:00:00 2001 From: jonnxie Date: Mon, 21 Mar 2022 14:57:59 +0800 Subject: [PATCH] Fixed loadAnimation function memory leak bug. --- base/VulkanglTFModel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/base/VulkanglTFModel.cpp b/base/VulkanglTFModel.cpp index 324f1f55..a4b5978c 100644 --- a/base/VulkanglTFModel.cpp +++ b/base/VulkanglTFModel.cpp @@ -1074,7 +1074,7 @@ void vkglTF::Model::loadAnimations(tinygltf::Model &gltfModel) for (size_t index = 0; index < accessor.count; index++) { sampler.inputs.push_back(buf[index]); } - + delete[] buf; for (auto input : sampler.inputs) { if (input < animation.start) { animation.start = input; @@ -1100,7 +1100,8 @@ void vkglTF::Model::loadAnimations(tinygltf::Model &gltfModel) for (size_t index = 0; index < accessor.count; index++) { sampler.outputsVec4.push_back(glm::vec4(buf[index], 0.0f)); } - break; + delete[] buf; + break; } case TINYGLTF_TYPE_VEC4: { glm::vec4 *buf = new glm::vec4[accessor.count]; @@ -1108,7 +1109,8 @@ void vkglTF::Model::loadAnimations(tinygltf::Model &gltfModel) for (size_t index = 0; index < accessor.count; index++) { sampler.outputsVec4.push_back(buf[index]); } - break; + delete[] buf; + break; } default: { std::cout << "unknown type" << std::endl;