From 23d44223e6bfc753d63cafe95be4f4b1e1b28630 Mon Sep 17 00:00:00 2001 From: Wavesonics Date: Wed, 24 Jun 2020 16:48:26 -0700 Subject: [PATCH] Fix memory leaks in RasterizerStorageDummy::free Lightmap capture data is now freed as well free() now also properly returns true or false based on if something was actually freed. --- drivers/dummy/rasterizer_dummy.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/dummy/rasterizer_dummy.h b/drivers/dummy/rasterizer_dummy.h index 4b33a58c23f..091951ba103 100644 --- a/drivers/dummy/rasterizer_dummy.h +++ b/drivers/dummy/rasterizer_dummy.h @@ -725,20 +725,25 @@ public: } bool free(RID p_rid) { - if (texture_owner.owns(p_rid)) { // delete the texture DummyTexture *texture = texture_owner.get(p_rid); texture_owner.free(p_rid); memdelete(texture); - } - - if (mesh_owner.owns(p_rid)) { + } else if (mesh_owner.owns(p_rid)) { // delete the mesh DummyMesh *mesh = mesh_owner.getornull(p_rid); mesh_owner.free(p_rid); memdelete(mesh); + } else if (lightmap_capture_data_owner.owns(p_rid)) { + // delete the lightmap + LightmapCapture *lightmap_capture = lightmap_capture_data_owner.getornull(p_rid); + lightmap_capture_data_owner.free(p_rid); + memdelete(lightmap_capture); + } else { + return false; } + return true; }