bugfix(arena): Fixed crash-bug which is triggered by cloning a string into a full arena.

When allocating in a full arena, the function 'ufn_arena_alloc' returns NULL.
Up to now, the string-clone function would try to copy to there.
Now it returs NULL as string-copy when that would've happened.
This commit is contained in:
Eric-Paul Ickhorn 2024-05-23 00:58:02 +02:00
parent ee22b5df5c
commit a5e78dca9a
1 changed files with 4 additions and 0 deletions

View File

@ -131,6 +131,10 @@ char * ufn_arena_clone_string(ufn_arena_s *arena, const char *string)
{
uint32_t len_string = strlen(string);
char *string_copy = ufn_arena_alloc(arena, len_string + 1);
if(string_copy == NULL)
{
return NULL;
}
memcpy(string_copy, string, len_string + 1);
return string_copy;
}