From 9f708489fadfa6c738a78bc2045fe1a2ceda0299 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Tue, 13 Sep 2022 08:19:14 -0700 Subject: Fix leaking of Mesh version and lod memory when freeing mesh in GLES3 --- drivers/gles3/storage/mesh_storage.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'drivers/gles3/storage') diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index e54ecd51c4..22d84eba93 100644 --- a/drivers/gles3/storage/mesh_storage.cpp +++ b/drivers/gles3/storage/mesh_storage.cpp @@ -554,6 +554,21 @@ void MeshStorage::mesh_clear(RID p_mesh) { glDeleteBuffers(1, &s.index_buffer); s.index_buffer = 0; } + + if (s.versions) { + memfree(s.versions); //reallocs, so free with memfree. + } + + if (s.lod_count) { + for (uint32_t j = 0; j < s.lod_count; j++) { + if (s.lods[j].index_buffer != 0) { + glDeleteBuffers(1, &s.lods[j].index_buffer); + s.lods[j].index_buffer = 0; + } + } + memdelete_arr(s.lods); + } + memdelete(mesh->surfaces[i]); } if (mesh->surfaces) { -- cgit v1.2.3