[Bf-blender-cvs] [3a5fbf112a0] blender-v3.2-release: Fix T98956: Crash removing some builtin attributes

Hans Goudey noreply at git.blender.org
Fri Jun 24 23:04:48 CEST 2022


Commit: 3a5fbf112a0d08a55b9a18928a3d1f318720c285
Author: Hans Goudey
Date:   Wed Jun 22 09:06:29 2022 -0500
Branches: blender-v3.2-release
https://developer.blender.org/rB3a5fbf112a0d08a55b9a18928a3d1f318720c285

Fix T98956: Crash removing some builtin attributes

An alternative to the solution in cebc5531e944 that avoids
using the CustomData_free_layer_named function that wasn't
added to 3.2 yet.

===================================================================

M	source/blender/blenkernel/intern/attribute_access.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index d33b64c493b..0f104fa9c9e 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -367,7 +367,7 @@ bool BuiltinCustomDataLayerProvider::try_delete(GeometryComponent &component) co
   }
 
   const int domain_size = component.attribute_domain_size(domain_);
-  int layer_index;
+  int layer_index = -1;
   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_)) {
@@ -380,6 +380,10 @@ bool BuiltinCustomDataLayerProvider::try_delete(GeometryComponent &component) co
     layer_index = CustomData_get_layer_index(custom_data, stored_type_);
   }
 
+  if (layer_index == -1) {
+    return false;
+  }
+
   const bool delete_success = CustomData_free_layer(
       custom_data, stored_type_, domain_size, layer_index);
   if (delete_success) {



More information about the Bf-blender-cvs mailing list