diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_geom.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_geom.cc index 5ecebdd849a..57a3066266f 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_geom.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_geom.cc @@ -117,11 +117,15 @@ Array polyline_fit_curve(Span points, return {}; } + if (r_cubic_array == nullptr) { + return {}; + } + Span r_cubic_array_span(reinterpret_cast(r_cubic_array), r_cubic_array_len * 3); Array curve_positions(r_cubic_array_span); /* Free the c-style array. */ - MEM_freeN(r_cubic_array); + free(r_cubic_array); return curve_positions; } @@ -153,11 +157,16 @@ IndexMask polyline_detect_corners(Span points, /* Error occurred, return. */ return IndexMask(); } + + if (r_corners == nullptr) { + return IndexMask(); + } + BLI_assert(samples_max < std::numeric_limits::max()); Span indices(reinterpret_cast(r_corners), r_corner_len); const IndexMask corner_mask = IndexMask::from_indices(indices, memory); /* Free the c-style array. */ - MEM_freeN(r_corners); + free(r_corners); return corner_mask; }