diff options
author | Martijn Versteegh <Baardaap> | 2021-11-11 18:25:10 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-11-11 18:25:10 +0300 |
commit | 7aa39b40f40c2b037f97e009eabf8d4698c41ee4 (patch) | |
tree | 1da38dfe15f714c4eeb060100a9944f81014b1d2 /source/blender/blenkernel/BKE_spline.hh | |
parent | d26d3cfe193793728cac77be9b44463a84a0f57e (diff) |
Fix: Prevent use of uninitialized memory when creating Bezier spline
When Constructing bezier splines from dna, the positions of the
left/right handles were set directly in the internal vectors, by
requesting a reference to them. The problem is that
BezierSpline::handle_positions_left() calls ensure_auto_handles()
before returning the reference. That function does some calculations on
uninitialized memory if the positions array is not yet filled.
Differential Revision: https://developer.blender.org/D13107
Diffstat (limited to 'source/blender/blenkernel/BKE_spline.hh')
-rw-r--r-- | source/blender/blenkernel/BKE_spline.hh | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_spline.hh b/source/blender/blenkernel/BKE_spline.hh index 8509b730709..55a4f6ffcfd 100644 --- a/source/blender/blenkernel/BKE_spline.hh +++ b/source/blender/blenkernel/BKE_spline.hh @@ -306,11 +306,23 @@ class BezierSpline final : public Spline { blender::Span<HandleType> handle_types_left() const; blender::MutableSpan<HandleType> handle_types_left(); blender::Span<blender::float3> handle_positions_left() const; - blender::MutableSpan<blender::float3> handle_positions_left(); + /** + * Get writable access to the hande position. + * + * \param write_only: pass true for an uninitialized spline, this prevents accessing + * uninitialized memory while autogenerating handles. + */ + blender::MutableSpan<blender::float3> handle_positions_left(bool write_only = false); blender::Span<HandleType> handle_types_right() const; blender::MutableSpan<HandleType> handle_types_right(); blender::Span<blender::float3> handle_positions_right() const; - blender::MutableSpan<blender::float3> handle_positions_right(); + /** + * Get writable access to the hande position. + * + * \param write_only: pass true for an uninitialized spline, this prevents accessing + * uninitialized memory while autogenerating handles. + */ + blender::MutableSpan<blender::float3> handle_positions_right(bool write_only = false); void ensure_auto_handles() const; void translate(const blender::float3 &translation) override; |