From 18da036ecc6e9dad3eaef4ca074e352dc87a0a9a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 4 Oct 2024 11:46:34 +1000 Subject: [PATCH] Fix crash deleting mask vertices The active vertex was only cleared when it was part of the active-spline (which isn't guaranteed). Duplicating & deleting left the active vertex pointing to freed memory. --- source/blender/editors/mask/mask_ops.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/source/blender/editors/mask/mask_ops.cc b/source/blender/editors/mask/mask_ops.cc index e6aedad0f8f..7d8a638c410 100644 --- a/source/blender/editors/mask/mask_ops.cc +++ b/source/blender/editors/mask/mask_ops.cc @@ -1431,15 +1431,21 @@ static int delete_exec(bContext *C, wmOperator * /*op*/) } if (count == 0) { + + /* Update active. */ + if (mask_layer->act_point) { + if (ARRAY_HAS_ITEM(mask_layer->act_point, spline->points, spline->tot_point)) { + mask_layer->act_point = nullptr; + } + } + if (spline == mask_layer->act_spline) { + mask_layer->act_spline = nullptr; + } + /* delete the whole spline */ BLI_remlink(&mask_layer->splines, spline); BKE_mask_spline_free(spline); - if (spline == mask_layer->act_spline) { - mask_layer->act_spline = nullptr; - mask_layer->act_point = nullptr; - } - BKE_mask_layer_shape_changed_remove(mask_layer, mask_layer_shape_ofs, tot_point_orig); } else {