Fix crash in gpencil.brush_reset_all referencing freed memory

A reference to the active brush was kept even when it was freed.
This commit is contained in:
Campbell Barton 2022-08-28 19:57:50 +10:00
parent 1f9d0acfa9
commit 219d109575
1 changed files with 5 additions and 2 deletions

View File

@ -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;