Commit 2e118ba3 authored by Tavian Barnes's avatar Tavian Barnes Committed by Kent Overstreet

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

memcpy's second parameter must not be NULL, even if size is zero.
Signed-off-by: default avatarTavian Barnes <tavianator@tavianator.com>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent efb2018e
...@@ -13,6 +13,7 @@ int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, g ...@@ -13,6 +13,7 @@ int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, g
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
if (d->size)
memcpy(data, d->data, d->size * element_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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment