[Bf-blender-cvs] [807be888a5c] geometry-nodes-simulation: Fix: Crash after mesh color attribute name commit

Christophe Hery noreply at git.blender.org
Mon Dec 19 19:05:25 CET 2022


Commit: 807be888a5c7706a185e0db827937a622eb4c3fa
Author: Christophe Hery
Date:   Fri Dec 16 09:42:30 2022 -0600
Branches: geometry-nodes-simulation
https://developer.blender.org/rB807be888a5c7706a185e0db827937a622eb4c3fa

Fix: Crash after mesh color attribute name commit

6514bb05ea5a138d8971 missed a null check when accessing the active
and default color attribute names, since the CustomData API does not
do that check itself.

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

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

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

diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index a53b0e66924..28bbc0ffae3 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -544,11 +544,15 @@ static void update_active_fdata_layers(Mesh &mesh, CustomData *fdata, CustomData
   }
 
   if (CustomData_has_layer(ldata, CD_PROP_BYTE_COLOR)) {
-    act = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, mesh.active_color_attribute);
-    CustomData_set_layer_active(fdata, CD_MCOL, act);
+    if (mesh.active_color_attribute != NULL) {
+      act = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, mesh.active_color_attribute);
+      CustomData_set_layer_active(fdata, CD_MCOL, act);
+    }
 
-    act = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, mesh.default_color_attribute);
-    CustomData_set_layer_render(fdata, CD_MCOL, act);
+    if (mesh.default_color_attribute != NULL) {
+      act = CustomData_get_named_layer(ldata, CD_PROP_BYTE_COLOR, mesh.default_color_attribute);
+      CustomData_set_layer_render(fdata, CD_MCOL, act);
+    }
 
     act = CustomData_get_clone_layer(ldata, CD_PROP_BYTE_COLOR);
     CustomData_set_layer_clone(fdata, CD_MCOL, act);



More information about the Bf-blender-cvs mailing list