Fix error setting the ID name in disabled alembic nurbs importe

This corrects code that's currently disabled, see `USE_NURBS` define.

The name passed to `BKE_curve_add` was overwritten,
bypassing uniqueness and utf8 encoding checks.

Longer names would cause a buffer overrun as the length of the source
data was passed to `BLI_strncpy` instead of the destination.

Reviewed By: sybren

Ref D12125
This commit is contained in:
Campbell Barton 2021-08-06 23:01:57 +10:00
parent 01c1b1e82e
commit 2796ee7da0
1 changed files with 1 additions and 3 deletions

View File

@ -90,7 +90,7 @@ static bool set_knots(const FloatArraySamplePtr &knots, float *&nu_knots)
void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSelector &sample_sel)
{
Curve *cu = static_cast<Curve *>(BKE_curve_add(bmain, "abc_curve", OB_SURF));
Curve *cu = static_cast<Curve *>(BKE_curve_add(bmain, m_data_name.c_str(), OB_SURF));
cu->actvert = CU_ACT_NONE;
std::vector<std::pair<INuPatchSchema, IObject>>::iterator it;
@ -180,8 +180,6 @@ void AbcNurbsReader::readObjectData(Main *bmain, const Alembic::Abc::ISampleSele
BLI_addtail(BKE_curve_nurbs_get(cu), nu);
}
BLI_strncpy(cu->id.name + 2, m_data_name.c_str(), m_data_name.size() + 1);
m_object = BKE_object_add_only_object(bmain, OB_SURF, m_object_name.c_str());
m_object->data = cu;
}