[Bf-blender-cvs] [54a3e0d8281] refactor-mesh-uv-map-generic: Fix memory overrun in CustomData_shallow_copy_remove_non_bmesh_attributes

Baardaap noreply at git.blender.org
Sat Dec 10 23:43:07 CET 2022


Commit: 54a3e0d82813fb0dbafca41185726c7a2ccc2a8f
Author: Baardaap
Date:   Sat Dec 10 23:41:20 2022 +0100
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB54a3e0d82813fb0dbafca41185726c7a2ccc2a8f

Fix memory overrun in CustomData_shallow_copy_remove_non_bmesh_attributes

CustomData maxlayer wasn't set, which would cause subsequent calls to CustomData_add_layer
to write outside the layers array.

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

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

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

diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index a3d3c0a26c6..dd9aaf99d32 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -2321,7 +2321,7 @@ CustomData CustomData_shallow_copy_remove_non_bmesh_attributes(const CustomData
   CustomData dst = *src;
   dst.layers = static_cast<CustomDataLayer *>(
       MEM_calloc_arrayN(dst_layers.size(), sizeof(CustomDataLayer), __func__));
-  dst.totlayer = dst_layers.size();
+  dst.maxlayer = dst.totlayer = dst_layers.size();
   memcpy(dst.layers, dst_layers.data(), dst_layers.as_span().size_in_bytes());
 
   CustomData_update_typemap(&dst);



More information about the Bf-blender-cvs mailing list