diff options
author | Campbell Barton <campbell@blender.org> | 2022-08-28 12:57:50 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-28 13:00:14 +0300 |
commit | 219d1095756fda2e54b6168eb65c93e3869722a6 (patch) | |
tree | a47a2512aa8d6313c7a7e3355a66b4f74f5dad67 /source/blender/editors/gpencil | |
parent | 1f9d0acfa9efa3634274eda8b9cd3f7846cc5a4f (diff) |
Fix crash in gpencil.brush_reset_all referencing freed memory
A reference to the active brush was kept even when it was freed.
Diffstat (limited to 'source/blender/editors/gpencil')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 7 |
1 files changed, 5 insertions, 2 deletions
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; |