Merge branch 'cm/reftable-0-length-memset'

Code clean-up.

* cm/reftable-0-length-memset:
  reftable: avoid undefined behaviour breaking t0032
This commit is contained in:
Junio C Hamano 2022-05-04 09:51:29 -07:00
commit 1c4411cce1

View File

@ -15,7 +15,8 @@ https://developers.google.com/open-source/licenses/bsd
static void strbuf_return_block(void *b, struct reftable_block *dest)
{
memset(dest->data, 0xff, dest->len);
if (dest->len)
memset(dest->data, 0xff, dest->len);
reftable_free(dest->data);
}
@ -56,7 +57,8 @@ void block_source_from_strbuf(struct reftable_block_source *bs,
static void malloc_return_block(void *b, struct reftable_block *dest)
{
memset(dest->data, 0xff, dest->len);
if (dest->len)
memset(dest->data, 0xff, dest->len);
reftable_free(dest->data);
}
@ -85,7 +87,8 @@ static uint64_t file_size(void *b)
static void file_return_block(void *b, struct reftable_block *dest)
{
memset(dest->data, 0xff, dest->len);
if (dest->len)
memset(dest->data, 0xff, dest->len);
reftable_free(dest->data);
}