From 9f708489fadfa6c738a78bc2045fe1a2ceda0299 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Tue, 13 Sep 2022 08:19:14 -0700 Subject: [PATCH] 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(+) diff --git a/drivers/gles3/storage/mesh_storage.cpp b/drivers/gles3/storage/mesh_storage.cpp index e54ecd51c44..22d84eba931 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) {