Merge pull request #65746 from clayjohn/GLES3-mem-leak

Fix leaking of Mesh version and lod memory when freeing mesh in GLES3
This commit is contained in:
Rémi Verschelde 2022-09-13 23:56:53 +02:00 committed by GitHub
commit 2e6ba5ff13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {