diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-07-23 10:25:28 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-07-24 17:17:53 +0300 |
commit | 66b7fea5769db2c0842d56e55c2d8482e60d399c (patch) | |
tree | 448a728600f0e39e408b3282541aac09caddfe82 | |
parent | caaf12cdba65982f7fdbecffd6c355ee7527d249 (diff) |
Fix T67450: Crash undoing edit-mode lattice resolution
-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; } |