diff options
author | YimingWu <xp8110@outlook.com> | 2019-09-13 15:59:39 +0300 |
---|---|---|
committer | YimingWu <xp8110@outlook.com> | 2019-09-13 16:43:40 +0300 |
commit | d4fb85036640505b5bcbd5e0ef69512de46aa0ad (patch) | |
tree | c66b75c4e4f02790a76c7310351d6876fc50c96a /source/blender | |
parent | 77399283d4133c50877f82b50801fcd3496bd145 (diff) |
Fix T69829: Gpencil sample memory leaks.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/gpencil.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c index 84efc007f58..a7301af3176 100644 --- a/source/blender/blenkernel/intern/gpencil.c +++ b/source/blender/blenkernel/intern/gpencil.c @@ -1481,10 +1481,9 @@ static MDeformVert *stroke_defvert_new_count(int count, int totweight, ListBase LinkData *ld; MDeformVert *dst = MEM_mallocN(count * sizeof(MDeformVert), "new_deformVert"); - dst->totweight = totweight; - for (i = 0; i < count; i++) { dst[i].dw = MEM_mallocN(sizeof(MDeformWeight) * totweight, "new_deformWeight"); + dst[i].totweight = totweight; j = 0; /* re-assign deform groups */ for (ld = def_nr_list->first; ld; ld = ld->next) { @@ -1674,7 +1673,7 @@ bool BKE_gpencil_sample_stroke(bGPDstroke *gps, const float dist, const bool sel int result_totweight; if (gps->dvert != NULL) { - stroke_defvert_create_nr_list(gps->dvert, count, &def_nr_list, &result_totweight); + stroke_defvert_create_nr_list(gps->dvert, gps->totpoints, &def_nr_list, &result_totweight); new_dv = stroke_defvert_new_count(count, result_totweight, &def_nr_list); } @@ -1730,13 +1729,17 @@ bool BKE_gpencil_sample_stroke(bGPDstroke *gps, const float dist, const bool sel } gps->points = new_pt; - MEM_freeN(pt); /* original */ + /* Free original vertex list. */ + MEM_freeN(pt); if (new_dv) { + /* Free original weight data. */ BKE_gpencil_free_stroke_weights(gps); + MEM_freeN(gps->dvert); while ((ld = BLI_pophead(&def_nr_list))) { MEM_freeN(ld); } + gps->dvert = new_dv; } |