diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-07-23 10:25:28 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-07-23 10:25:28 +0300 |
commit | 34ad6da4a06ef46cd19945f61cc5f968538546a8 (patch) | |
tree | 68cacbc16620765f212a3778d3f2f78447bd7508 /source/blender/editors/lattice | |
parent | 07f3ad06fc0900f719294c7b59598ac58e410dea (diff) |
Fix T67450: Crash undoing edit-mode lattice resolution
Diffstat (limited to 'source/blender/editors/lattice')
-rw-r--r-- | source/blender/editors/lattice/editlattice_undo.c | 14 |
1 files changed, 12 insertions, 2 deletions
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; } |