diff --git a/source/blender/blenkernel/BKE_fcurve.hh b/source/blender/blenkernel/BKE_fcurve.hh index 43e2f5245eb..99f529880ab 100644 --- a/source/blender/blenkernel/BKE_fcurve.hh +++ b/source/blender/blenkernel/BKE_fcurve.hh @@ -482,8 +482,8 @@ bool BKE_fcurve_bezt_subdivide_handles(BezTriple *bezt, * * \param new_totvert: new number of elements in the FCurve's `bezt` array. * - * \note When increasing the size of the array, newly added elements are not initialized. That is - * left to the caller. + * \note When increasing the size of the array, newly added elements (that is, in the + * [old_totvert..new_totvert) interval) are zero-initialized. */ void BKE_fcurve_bezt_resize(FCurve *fcu, int new_totvert); diff --git a/source/blender/blenkernel/intern/fcurve.cc b/source/blender/blenkernel/intern/fcurve.cc index 0d9ee282c0c..454b2b8497f 100644 --- a/source/blender/blenkernel/intern/fcurve.cc +++ b/source/blender/blenkernel/intern/fcurve.cc @@ -1622,6 +1622,14 @@ void BKE_fcurve_bezt_resize(FCurve *fcu, const int new_totvert) fcu->bezt = static_cast( MEM_reallocN(fcu->bezt, new_totvert * sizeof(*(fcu->bezt)))); + + /* Zero out all the newly-allocated beztriples. This is necessary, as it is likely that only some + * of the fields will actually be updated by the caller. */ + const int old_totvert = fcu->totvert; + if (new_totvert > old_totvert) { + memset(&fcu->bezt[old_totvert], 0, sizeof(fcu->bezt[0]) * (new_totvert - old_totvert)); + } + fcu->totvert = new_totvert; }