Fix T99576: Guard against empty names when removing attributes

It's possible for misbehaving scripts written before 3.3 to reach
this state and crash Blender. With this change, the error is reduced
to a Python exception.

Differential Revision: https://developer.blender.org/D15724
This commit is contained in:
Tom Edwards 2022-08-29 14:45:55 -05:00 committed by Hans Goudey
parent 68487cff95
commit 35df9f80b9
Notes: blender-bot 2023-02-14 09:43:37 +01:00
Referenced by issue #99576, Crash in BKE_mesh_minmax
1 changed files with 4 additions and 0 deletions

View File

@ -288,6 +288,10 @@ CustomDataLayer *BKE_id_attribute_duplicate(ID *id, const char *name, ReportList
bool BKE_id_attribute_remove(ID *id, const char *name, ReportList *reports)
{
using namespace blender::bke;
if (!name || name[0] == '\0') {
BKE_report(reports, RPT_ERROR, "The attribute name must not be empty");
return false;
}
if (BKE_id_attribute_required(id, name)) {
BKE_report(reports, RPT_ERROR, "Attribute is required and can't be removed");
return false;