diff options
author | Antonioya <blendergit@gmail.com> | 2018-08-08 13:17:00 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-08-08 13:19:20 +0300 |
commit | 08e49c034b318fa430f2b783b3a3fac089da5f9b (patch) | |
tree | bd5b3fca1664cbc5865ab18910ff3b2b9514aed6 | |
parent | 6a07818e8fb3cdc003d6734f0bf79676f6104385 (diff) |
GP: Fix unreported segment fault with some old files
In some corner situations for old files, the weights array could not be initialized properly.
-rw-r--r-- | source/blender/blenkernel/intern/gpencil_modifier.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c b/source/blender/blenkernel/intern/gpencil_modifier.c index 3c2196afb18..d1c455f64e1 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier.c +++ b/source/blender/blenkernel/intern/gpencil_modifier.c @@ -257,6 +257,11 @@ void BKE_gpencil_simplify_stroke(bGPDstroke *gps, float factor) /* first create temp data and convert points to 2D */ vec2f *points2d = MEM_mallocN(sizeof(vec2f) * gps->totpoints, "GP Stroke temp 2d points"); + /* for some old files, the weights array could not be initializated */ + if (gps->dvert == NULL) { + gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); + } + gpencil_stroke_project_2d(gps->points, gps->totpoints, points2d); gpencil_rdp_stroke(gps, points2d, factor); @@ -271,6 +276,11 @@ void BKE_gpencil_simplify_fixed(bGPDstroke *gps) return; } + /* for some old files, the weights array could not be initializated */ + if (gps->dvert == NULL) { + gps->dvert = MEM_callocN(sizeof(MDeformVert) * gps->totpoints, "gp_stroke_weights"); + } + /* save points */ bGPDspoint *old_points = MEM_dupallocN(gps->points); MDeformVert *old_dvert = MEM_dupallocN(gps->dvert); |