Commit: 34ad6da4a06ef46cd19945f61cc5f968538546a8
Author: Campbell Barton
Date:   Tue Jul 23 17:25:28 2019 +1000
Branches: master
https://developer.blender.org/rB34ad6da4a06ef46cd19945f61cc5f968538546a8

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

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to