Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2021-06-17 14:40:08 +0300
committerJacques Lucke <jacques@blender.org>2021-06-17 14:40:08 +0300
commit56db09e2fda694ff2b171913d494c1ab8e20d398 (patch)
treec5ec97540e995f2d9a66346dfda7c2948387ff68 /source/blender/blenkernel/intern/geometry_component_curve.cc
parent1388e9de8afe187f85ad857e864d7463ff8ede55 (diff)
Geometry Nodes: fix ownership issue in spline to points conversion
Previously, `VArray_For_SplineToPoint` did not take ownership of the virtual array leading to use-after-free errors.
Diffstat (limited to 'source/blender/blenkernel/intern/geometry_component_curve.cc')
-rw-r--r--source/blender/blenkernel/intern/geometry_component_curve.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/geometry_component_curve.cc b/source/blender/blenkernel/intern/geometry_component_curve.cc
index de8dc355557..bc85305fea8 100644
--- a/source/blender/blenkernel/intern/geometry_component_curve.cc
+++ b/source/blender/blenkernel/intern/geometry_component_curve.cc
@@ -240,14 +240,18 @@ static GVArrayPtr adapt_curve_domain_point_to_spline(const CurveEval &curve, GVA
* unless it is necessary (in that case the materialize functions will be called).
*/
template<typename T> class VArray_For_SplineToPoint final : public VArray<T> {
+ GVArrayPtr original_varray_;
/* Store existing data materialized if it was not already a span. This is expected
* to be worth it because a single spline's value will likely be accessed many times. */
- VArray_Span<T> original_data_;
+ fn::GVArray_Span<T> original_data_;
Array<int> offsets_;
public:
- VArray_For_SplineToPoint(const VArray<T> &original_varray, Array<int> offsets)
- : VArray<T>(offsets.last()), original_data_(original_varray), offsets_(std::move(offsets))
+ VArray_For_SplineToPoint(GVArrayPtr original_varray, Array<int> offsets)
+ : VArray<T>(offsets.last()),
+ original_varray_(std::move(original_varray)),
+ original_data_(*original_varray_),
+ offsets_(std::move(offsets))
{
}
@@ -309,7 +313,7 @@ static GVArrayPtr adapt_curve_domain_spline_to_point(const CurveEval &curve, GVA
Array<int> offsets = curve.control_point_offsets();
new_varray = std::make_unique<fn::GVArray_For_EmbeddedVArray<T, VArray_For_SplineToPoint<T>>>(
- offsets.last(), *varray->typed<T>(), std::move(offsets));
+ offsets.last(), std::move(varray), std::move(offsets));
});
return new_varray;
}