[Bf-blender-cvs] [219d1095756] blender-v3.3-release: Fix crash in gpencil.brush_reset_all referencing freed memory

Campbell Barton noreply at git.blender.org
Sun Aug 28 12:18:38 CEST 2022


Commit: 219d1095756fda2e54b6168eb65c93e3869722a6
Author: Campbell Barton
Date:   Sun Aug 28 19:57:50 2022 +1000
Branches: blender-v3.3-release
https://developer.blender.org/rB219d1095756fda2e54b6168eb65c93e3869722a6

Fix crash in gpencil.brush_reset_all referencing freed memory

A reference to the active brush was kept even when it was freed.

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

M	source/blender/editors/gpencil/gpencil_data.c

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

diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index b7ac73b9692..340288b2d74 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -2076,6 +2076,9 @@ static void gpencil_brush_delete_mode_brushes(Main *bmain,
     }
 
     BKE_brush_delete(bmain, brush);
+    if (brush == brush_active) {
+      brush_active = NULL;
+    }
   }
 }
 
@@ -2109,8 +2112,8 @@ static int gpencil_brush_reset_all_exec(bContext *C, wmOperator *UNUSED(op))
 
   char tool = '0';
   if (paint) {
-    Brush *brush_active = paint->brush;
-    if (brush_active) {
+    if (paint->brush) {
+      Brush *brush_active = paint->brush;
       switch (mode) {
         case CTX_MODE_PAINT_GPENCIL: {
           tool = brush_active->gpencil_tool;



More information about the Bf-blender-cvs mailing list