Cleanup: avoid zero byte memcpy

Asan reports warnings because of this.
This commit is contained in:
Jacques Lucke 2020-07-23 17:55:05 +02:00
parent cf123da640
commit 67857b5d9f
1 changed files with 7 additions and 5 deletions

View File

@ -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) {