diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-05-27 07:03:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-05-27 07:05:44 +0300 |
commit | 2eead82ce0e7c7c2eb5be252fbcdb62f2c1a30f9 (patch) | |
tree | d685eaa3571d1932ea5fd565eadd895f5f3299dc /source/blender | |
parent | 19809c83850904ad4659114dd229b42b29dcf426 (diff) |
CustomData: assert on bad arguments to free
Assert the index is in-range for the layer type.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/customdata.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c index 331714301d5..0939d35ed8d 100644 --- a/source/blender/blenkernel/intern/customdata.c +++ b/source/blender/blenkernel/intern/customdata.c @@ -1944,17 +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) { - 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; + BLI_assert(index >= index_first); + if ((index_first == -1) || (n < 0)) { + return false; + } + BLI_assert(data->layers[index].type == type); + customData_free_layer__internal(&data->layers[index], totelem); for (i = index + 1; i < data->totlayer; ++i) |