[Bf-blender-cvs] [7bde2844ae8] blender-v2.92-release: Fix memory leak in boundary brush preview data

Pablo Dobarro noreply at git.blender.org
Wed Feb 3 20:56:41 CET 2021


Commit: 7bde2844ae8fcf5547edc495a0518cfdad49ffff
Author: Pablo Dobarro
Date:   Wed Feb 3 20:54:30 2021 +0100
Branches: blender-v2.92-release
https://developer.blender.org/rB7bde2844ae8fcf5547edc495a0518cfdad49ffff

Fix memory leak in boundary brush preview data

The edge preview data of the boundary needs to be freed with the
boundary data created for the brush. Also, all data for the
ScultpSession preview that is used to render the cursor needs to be
freed with the ##SculptSession##.

Found by Jacques Lucke

Reviewed By: JacquesLucke

Differential Revision: https://developer.blender.org/D10173

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

M	source/blender/blenkernel/intern/paint.c
M	source/blender/editors/sculpt_paint/sculpt_boundary.c

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

diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 4eecf3a3a87..7c65f118cf4 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -1487,6 +1487,14 @@ void BKE_sculptsession_free(Object *ob)
       MEM_SAFE_FREE(ss->pose_ik_chain_preview);
     }
 
+    if (ss->boundary_preview) {
+      MEM_SAFE_FREE(ss->boundary_preview->vertices);
+      MEM_SAFE_FREE(ss->boundary_preview->edges);
+      MEM_SAFE_FREE(ss->boundary_preview->distance);
+      MEM_SAFE_FREE(ss->boundary_preview->edit_info);
+      MEM_SAFE_FREE(ss->boundary_preview);
+    }
+
     BKE_sculptsession_free_vwpaint_data(ob->sculpt);
 
     MEM_freeN(ss);
diff --git a/source/blender/editors/sculpt_paint/sculpt_boundary.c b/source/blender/editors/sculpt_paint/sculpt_boundary.c
index 64f2542dcbe..0cfb6f17adb 100644
--- a/source/blender/editors/sculpt_paint/sculpt_boundary.c
+++ b/source/blender/editors/sculpt_paint/sculpt_boundary.c
@@ -530,6 +530,7 @@ SculptBoundary *SCULPT_boundary_data_init(Object *object,
 void SCULPT_boundary_data_free(SculptBoundary *boundary)
 {
   MEM_SAFE_FREE(boundary->vertices);
+  MEM_SAFE_FREE(boundary->edges);
   MEM_SAFE_FREE(boundary->distance);
   MEM_SAFE_FREE(boundary->edit_info);
   MEM_SAFE_FREE(boundary->bend.pivot_positions);



More information about the Bf-blender-cvs mailing list