Cleanup: Fix custom data memcpy call null argument

The data was only null if the size was also zero, but it's simple
to avoid the ASAN warning anyway.
This commit is contained in:
Hans Goudey
2023-04-20 17:30:59 -04:00
parent f6ec11741c
commit 491f098edf

View File

@@ -431,7 +431,9 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t
/* expand array */
newlayer = MEM_calloc_arrayN((cdf->totlayer + 1), sizeof(CDataFileLayer), "CDataFileLayer");
memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer) * cdf->totlayer);
if (cdf->totlayer > 0) {
memcpy(newlayer, cdf->layer, sizeof(CDataFileLayer) * cdf->totlayer);
}
cdf->layer = newlayer;
cdf->totlayer++;