[Bf-blender-cvs] [67857b5d9f3] master: Cleanup: avoid zero byte memcpy

Jacques Lucke noreply at git.blender.org
Thu Jul 23 17:57:42 CEST 2020


Commit: 67857b5d9f39d7bf16131c99451617b5c27d0938
Author: Jacques Lucke
Date:   Thu Jul 23 17:55:05 2020 +0200
Branches: master
https://developer.blender.org/rB67857b5d9f39d7bf16131c99451617b5c27d0938

Cleanup: avoid zero byte memcpy

Asan reports warnings because of this.

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

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

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

diff --git a/source/blender/blenkernel/intern/customdata.c b/source/blender/blenkernel/intern/customdata.c
index 22d4af6fa39..7bf11d86a63 100644
--- a/source/blender/blenkernel/intern/customdata.c
+++ b/source/blender/blenkernel/intern/customdata.c
@@ -2643,11 +2643,13 @@ static CustomDataLayer *customData_add_layer__internal(CustomData *data,
   }
 
   if (alloctype == CD_DUPLICATE && layerdata) {
-    if (typeInfo->copy) {
-      typeInfo->copy(layerdata, newlayerdata, totelem);
-    }
-    else {
-      memcpy(newlayerdata, layerdata, (size_t)totelem * typeInfo->size);
+    if (totelem > 0) {
+      if (typeInfo->copy) {
+        typeInfo->copy(layerdata, newlayerdata, totelem);
+      }
+      else {
+        memcpy(newlayerdata, layerdata, (size_t)totelem * typeInfo->size);
+      }
     }
   }
   else if (alloctype == CD_DEFAULT) {



More information about the Bf-blender-cvs mailing list