1

bcachefs: darray: Don't pass NULL to memcpy()

memcpy's second parameter must not be NULL, even if size is zero.

Signed-off-by: Tavian Barnes <tavianator@tavianator.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Tavian Barnes 2024-06-21 16:29:32 -04:00 committed by Kent Overstreet
parent efb2018e4d
commit 2e118ba36d

View File

@ -13,7 +13,8 @@ int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, g
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
memcpy(data, d->data, d->size * element_size); if (d->size)
memcpy(data, d->data, d->size * element_size);
if (d->data != d->preallocated) if (d->data != d->preallocated)
kvfree(d->data); kvfree(d->data);
d->data = data; d->data = data;