[Bf-blender-cvs] [66b7fea5769] blender-v2.80-release: Fix T67450: Crash undoing edit-mode lattice resolution

Campbell Barton noreply at git.blender.org
Wed Jul 24 16:28:48 CEST 2019


Commit: 66b7fea5769db2c0842d56e55c2d8482e60d399c
Author: Campbell Barton
Date:   Tue Jul 23 17:25:28 2019 +1000
Branches: blender-v2.80-release
https://developer.blender.org/rB66b7fea5769db2c0842d56e55c2d8482e60d399c

Fix T67450: Crash undoing edit-mode lattice resolution

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

M	source/blender/editors/lattice/editlattice_undo.c

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

diff --git a/source/blender/editors/lattice/editlattice_undo.c b/source/blender/editors/lattice/editlattice_undo.c
index 5164970198e..abc5224c4d6 100644
--- a/source/blender/editors/lattice/editlattice_undo.c
+++ b/source/blender/editors/lattice/editlattice_undo.c
@@ -68,9 +68,19 @@ typedef struct UndoLattice {
 
 static void undolatt_to_editlatt(UndoLattice *ult, EditLatt *editlatt)
 {
-  int len = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw;
+  const int len_src = ult->pntsu * ult->pntsv * ult->pntsw;
+  const int len_dst = editlatt->latt->pntsu * editlatt->latt->pntsv * editlatt->latt->pntsw;
+  if (len_src != len_dst) {
+    MEM_freeN(editlatt->latt->def);
+    editlatt->latt->def = MEM_dupallocN(ult->def);
+  }
+  else {
+    memcpy(editlatt->latt->def, ult->def, sizeof(BPoint) * len_src);
+  }
 
-  memcpy(editlatt->latt->def, ult->def, sizeof(BPoint) * len);
+  editlatt->latt->pntsu = ult->pntsu;
+  editlatt->latt->pntsv = ult->pntsv;
+  editlatt->latt->pntsw = ult->pntsw;
   editlatt->latt->actbp = ult->actbp;
 }



More information about the Bf-blender-cvs mailing list