Fix a bug in the UUID assigner

In the UUID assigner, malloc() was  used somewhere where it would have
been correct to use realloc().
This commit is contained in:
Eric-Paul Ickhorn 2024-09-12 23:25:00 +02:00
parent e3e4e5ee84
commit 81e10aa64b
1 changed files with 5 additions and 1 deletions

View File

@ -65,7 +65,11 @@ vx_uuid_block_s * vx_allocate_new_id_block(vx_uuid_table_s *table)
if(table->num_blocks >= table->block_capacity) if(table->num_blocks >= table->block_capacity)
{ {
table->block_capacity *= 2; table->block_capacity *= 2;
table->blocks = malloc(table->block_capacity * sizeof(vx_uuid_block_s *)); if( ! table->block_capacity)
{
table->block_capacity = 32;
}
table->blocks = realloc(table->blocks, table->block_capacity * sizeof(vx_uuid_block_s *));
} }
table->blocks[table->num_blocks] = malloc(sizeof(vx_uuid_block_s)); table->blocks[table->num_blocks] = malloc(sizeof(vx_uuid_block_s));
block = table->blocks[table->num_blocks]; block = table->blocks[table->num_blocks];