Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2017-05-26 16:19:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2017-05-26 16:30:20 +0300
commitac66fb193f80847fd4fc1b46413ebb3199ebbf1b (patch)
treeff77444aa581eca763300305c4785720bd835004 /source/blender/blenkernel
parentbddd9d809d2c291eb0a92220195908c51ae2ce80 (diff)
Fix freeing all custom-data layers
Would crash when the active index was out of range, since there is no reason to use the active layer when freeing all, free the first instead.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/customdata.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 7c3f0ac630d..331714301d5 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -1944,11 +1944,16 @@ void *CustomData_add_layer_named(CustomData *data, int type, int alloctype,
bool CustomData_free_layer(CustomData *data, int type, int totelem, int index)
{
- const int n = index - CustomData_get_layer_index(data, type);
- int i;
-
- if (index < 0)
+ if (index < 0) {
+ return false;
+ }
+ const int index_first = CustomData_get_layer_index(data, type);
+ if (index_first == -1) {
return false;
+ }
+
+ const int n = index - index_first;
+ int i;
customData_free_layer__internal(&data->layers[index], totelem);
@@ -1993,8 +1998,10 @@ bool CustomData_free_layer_active(CustomData *data, int type, int totelem)
void CustomData_free_layers(CustomData *data, int type, int totelem)
{
- while (CustomData_has_layer(data, type))
- CustomData_free_layer_active(data, type, totelem);
+ const int index = CustomData_get_layer_index(data, type);
+ while (CustomData_free_layer(data, type, totelem, index)) {
+ /* pass */
+ }
}
bool CustomData_has_layer(const CustomData *data, int type)