Fix T67450: Crash undoing edit-mode lattice resolution

This commit is contained in:
Campbell Barton 2019-07-23 17:25:28 +10:00
parent 07f3ad06fc
commit 34ad6da4a0
Notes: blender-bot 2023-02-14 08:06:33 +01:00
Referenced by issue #67450, Undo breaks lattice
1 changed files with 12 additions and 2 deletions

View File

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