Merge pull request #6614 from Dwedit/copy_load_info_bugfix

Two fixes for copy_load_info.c
This commit is contained in:
Twinaphex 2018-04-24 18:08:27 +02:00 committed by GitHub
commit bd01ab80ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -37,12 +37,15 @@ static struct retro_game_info* clone_retro_game_info(const
dest->data = NULL;
dest->path = strcpy_alloc(src->path);
data = malloc(src->size);
if (data)
if (src->size && src->data)
{
memcpy(data, src->data, src->size);
dest->data = data;
data = malloc(src->size);
if (data)
{
memcpy(data, src->data, src->size);
dest->data = data;
}
}
dest->size = src->size;
@ -77,9 +80,13 @@ static struct string_list *string_list_clone(
dest->size = src->size;
dest->cap = src->cap;
if (dest->cap < dest->size)
{
dest->cap = dest->size;
}
elems = (struct string_list_elem*)
calloc(dest->size, sizeof(struct string_list_elem));
calloc(dest->cap, sizeof(struct string_list_elem));
if (!elems)
{