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:
parent
ee22b5df5c
commit
a5e78dca9a
|
@ -131,6 +131,10 @@ char * ufn_arena_clone_string(ufn_arena_s *arena, const char *string)
|
||||||
{
|
{
|
||||||
uint32_t len_string = strlen(string);
|
uint32_t len_string = strlen(string);
|
||||||
char *string_copy = ufn_arena_alloc(arena, len_string + 1);
|
char *string_copy = ufn_arena_alloc(arena, len_string + 1);
|
||||||
|
if(string_copy == NULL)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
memcpy(string_copy, string, len_string + 1);
|
memcpy(string_copy, string, len_string + 1);
|
||||||
return string_copy;
|
return string_copy;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue