Fix T98956: Crash removing some builtin attributes
For example, the "id" attribute is stored as a named attribute. If it doesn't exist already, `layer_index` was uninitialized, causing issues with `CustomData_free_layer`. The fix is to use the generic function to free a named layer in that case. Eventually the other case will go away as T95965 is finished.
This commit is contained in:
parent
785931fc3c
commit
cebc5531e9
Notes:
blender-bot
2023-02-14 19:45:25 +01:00
Referenced by issue #98956, Geometry Nodes crash when using "Store Named Attribute" with name "id" Referenced by issue #98661, 3.2: Potential candidates for corrective releases
|
@ -375,27 +375,24 @@ bool BuiltinCustomDataLayerProvider::try_delete(GeometryComponent &component) co
|
|||
}
|
||||
|
||||
const int domain_num = component.attribute_domain_num(domain_);
|
||||
int layer_index;
|
||||
if (stored_as_named_attribute_) {
|
||||
for (const int i : IndexRange(custom_data->totlayer)) {
|
||||
if (custom_data_layer_matches_attribute_id(custom_data->layers[i], name_)) {
|
||||
layer_index = i;
|
||||
break;
|
||||
if (CustomData_free_layer_named(custom_data, name_.c_str(), domain_num)) {
|
||||
if (custom_data_access_.update_custom_data_pointers) {
|
||||
custom_data_access_.update_custom_data_pointers(component);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
layer_index = CustomData_get_layer_index(custom_data, stored_type_);
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool delete_success = CustomData_free_layer(
|
||||
custom_data, stored_type_, domain_num, layer_index);
|
||||
if (delete_success) {
|
||||
const int layer_index = CustomData_get_layer_index(custom_data, stored_type_);
|
||||
if (CustomData_free_layer(custom_data, stored_type_, domain_num, layer_index)) {
|
||||
if (custom_data_access_.update_custom_data_pointers) {
|
||||
custom_data_access_.update_custom_data_pointers(component);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return delete_success;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BuiltinCustomDataLayerProvider::try_create(GeometryComponent &component,
|
||||
|
|
Loading…
Reference in New Issue