[Bf-blender-cvs] [32e9c9802eb] master: Cleanup: Add assert for customdata realloc size

Hans Goudey noreply at git.blender.org
Fri Jul 1 02:40:29 CEST 2022


Commit: 32e9c9802eb3fb3f85c3dbf791e49ef74a9e2b0a
Author: Hans Goudey
Date:   Thu Jun 30 19:27:41 2022 -0500
Branches: master
https://developer.blender.org/rB32e9c9802eb3fb3f85c3dbf791e49ef74a9e2b0a

Cleanup: Add assert for customdata realloc size

This gives a more clear error than finding the error with the signed
to unsigned conversion for size_t.

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

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

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

diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index bb5b2ee0836..2cd829a7f0b 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -2329,6 +2329,7 @@ bool CustomData_merge(const CustomData *source,
 
 void CustomData_realloc(CustomData *data, int totelem)
 {
+  BLI_assert(totelem > 0);
   for (int i = 0; i < data->totlayer; i++) {
     CustomDataLayer *layer = &data->layers[i];
     const LayerTypeInfo *typeInfo;



More information about the Bf-blender-cvs mailing list