[Bf-blender-cvs] [86214740caf] temp-pbvh-split: Fix knife tool use-after free on completion

Campbell Barton noreply at git.blender.org
Fri Jun 3 01:16:28 CEST 2022


Commit: 86214740caf90385ea20eae2293df7b2589b5e73
Author: Campbell Barton
Date:   Wed May 11 16:19:17 2022 +1000
Branches: temp-pbvh-split
https://developer.blender.org/rB86214740caf90385ea20eae2293df7b2589b5e73

Fix knife tool use-after free on completion

Regression in [0] accessed knife data after it had been freed.

[0]: f87029f7b13142499a37fb311a721d99bb1aecd7

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

M	source/blender/editors/mesh/editmesh_knife.c

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

diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c
index ee40431c101..81cfe4f85f1 100644
--- a/source/blender/editors/mesh/editmesh_knife.c
+++ b/source/blender/editors/mesh/editmesh_knife.c
@@ -4391,7 +4391,8 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
         ED_workspace_status_text(C, NULL);
 
         return OPERATOR_CANCELLED;
-      case KNF_MODAL_CONFIRM:
+      case KNF_MODAL_CONFIRM: {
+        const bool changed = (kcd->totkvert != 0);
         /* finish */
         ED_region_tag_redraw(kcd->region);
 
@@ -4400,11 +4401,11 @@ static int knifetool_modal(bContext *C, wmOperator *op, const wmEvent *event)
         ED_workspace_status_text(C, NULL);
 
         /* Cancel to prevent undo push for empty cuts. */
-        if (kcd->totkvert == 0) {
+        if (!changed) {
           return OPERATOR_CANCELLED;
         }
-
         return OPERATOR_FINISHED;
+      }
       case KNF_MODAL_UNDO:
         if (BLI_stack_is_empty(kcd->undostack)) {
           ED_region_tag_redraw(kcd->region);



More information about the Bf-blender-cvs mailing list