Fix #105860: Out of bounds active layer index caused crashes elsewhere

Setting a negative active layer index was possible, causing a crash
when adding new layers (for example).

Clamp the active index when assigning from RNA.
This commit is contained in:
Campbell Barton
2023-03-23 13:33:41 +11:00
parent 2de2db0f79
commit eaec2175ad

View File

@@ -108,6 +108,12 @@
Mesh *me = rna_mesh(ptr); \
CustomData *data = rna_mesh_##customdata_type(ptr); \
if (data) { \
if (UNLIKELY(value < 0)) { \
value = 0; \
} \
else if (value > 0) { \
value = min_ii(value, CustomData_number_of_layers(data, layer_type) - 1); \
} \
CustomData_set_layer_##active_type(data, layer_type, value); \
BKE_mesh_tessface_clear(me); \
} \