diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2024-06-21 16:29:32 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-07-14 21:52:37 -0400 |
commit | 2e118ba36d56acf78084518dfb7cb53b1d417da0 (patch) | |
tree | 2a51bedb0da183ce0f8c1a0673dca637e946d92c /fs/bcachefs | |
parent | efb2018e4d238cc205690ac62c0917d60d291e66 (diff) |
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>
Diffstat (limited to 'fs/bcachefs')
-rw-r--r-- | fs/bcachefs/darray.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/fs/bcachefs/darray.c b/fs/bcachefs/darray.c index ac35b8b705ae..b7d223f85873 100644 --- a/fs/bcachefs/darray.c +++ b/fs/bcachefs/darray.c @@ -13,7 +13,8 @@ int __bch2_darray_resize(darray_char *d, size_t element_size, size_t new_size, g if (!data) 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) kvfree(d->data); d->data = data; |