From 6cc4c68dad795a4ac63e06a1d63a1865f74210bd Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Fri, 27 Mar 2020 14:49:46 +0100 Subject: Fix T75121: Memory leak in Surface Smooth The brush was allocating new memory for storing the displacemnets at the beginning of each stroke step and not freeing them. Reviewed By: jbakker Maniphest Tasks: T75121 Differential Revision: https://developer.blender.org/D7254 --- source/blender/editors/sculpt_paint/sculpt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 73173571277..dbb89617b08 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -3458,7 +3458,9 @@ static void do_surface_smooth_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, in Brush *brush = BKE_paint_brush(&sd->paint); SculptSession *ss = ob->sculpt; - if (ss->cache->mirror_symmetry_pass == 0 && ss->cache->radial_symmetry_pass == 0) { + if (ss->cache->first_time && ss->cache->mirror_symmetry_pass == 0 && + ss->cache->radial_symmetry_pass == 0) { + BLI_assert(ss->cache->surface_smooth_laplacian_disp == NULL); ss->cache->surface_smooth_laplacian_disp = MEM_callocN( SCULPT_vertex_count_get(ss) * 3 * sizeof(float), "HC smooth laplacian b"); } @@ -6860,9 +6862,9 @@ static const char *sculpt_tool_name(Sculpt *sd) void SCULPT_cache_free(StrokeCache *cache) { - if (cache->dial) { - MEM_freeN(cache->dial); - } + MEM_SAFE_FREE(cache->dial); + MEM_SAFE_FREE(cache->surface_smooth_laplacian_disp); + if (cache->pose_ik_chain) { SCULPT_pose_ik_chain_free(cache->pose_ik_chain); } -- cgit v1.2.3