[Bf-blender-cvs] [6cc4c68dad7] master: Fix T75121: Memory leak in Surface Smooth

Pablo Dobarro noreply at git.blender.org
Thu Apr 2 15:36:39 CEST 2020


Commit: 6cc4c68dad795a4ac63e06a1d63a1865f74210bd
Author: Pablo Dobarro
Date:   Fri Mar 27 14:49:46 2020 +0100
Branches: master
https://developer.blender.org/rB6cc4c68dad795a4ac63e06a1d63a1865f74210bd

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

===================================================================

M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

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);
   }



More information about the Bf-blender-cvs mailing list