mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 08:30:16 +00:00
Free before doing strdup
This commit is contained in:
parent
1d632e26fe
commit
189f8d58ec
55
playlist.c
55
playlist.c
@ -181,12 +181,41 @@ void playlist_update(playlist_t *playlist, size_t idx,
|
||||
|
||||
entry = &playlist->entries[idx];
|
||||
|
||||
entry->path = path ? strdup(path) : entry->path;
|
||||
entry->label = label ? strdup(label) : entry->label;
|
||||
entry->core_path = core_path ? strdup(core_path) : entry->core_path;
|
||||
entry->core_name = core_name ? strdup(core_name) : entry->core_name;
|
||||
entry->db_name = db_name ? strdup(db_name) : entry->db_name;
|
||||
entry->crc32 = crc32 ? strdup(crc32) : entry->crc32;
|
||||
if (path)
|
||||
{
|
||||
free(entry->path);
|
||||
entry->path = strdup(path);
|
||||
}
|
||||
|
||||
if (label)
|
||||
{
|
||||
free(entry->label);
|
||||
entry->label = strdup(label);
|
||||
}
|
||||
|
||||
if (core_path)
|
||||
{
|
||||
free(entry->core_path);
|
||||
entry->core_path = strdup(core_path);
|
||||
}
|
||||
|
||||
if (core_name)
|
||||
{
|
||||
free(entry->core_name);
|
||||
entry->core_name = strdup(core_name);
|
||||
}
|
||||
|
||||
if (db_name)
|
||||
{
|
||||
free(entry->db_name);
|
||||
entry->db_name = strdup(db_name);
|
||||
}
|
||||
|
||||
if (crc32)
|
||||
{
|
||||
free(entry->crc32);
|
||||
entry->crc32 = strdup(crc32);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -397,15 +426,29 @@ static bool playlist_read_file(
|
||||
continue;
|
||||
|
||||
if (*buf[0])
|
||||
{
|
||||
free(entry->path);
|
||||
entry->path = strdup(buf[0]);
|
||||
}
|
||||
if (*buf[1])
|
||||
{
|
||||
free(entry->label);
|
||||
entry->label = strdup(buf[1]);
|
||||
}
|
||||
free(entry->core_path);
|
||||
entry->core_path = strdup(buf[2]);
|
||||
free(entry->core_name);
|
||||
entry->core_name = strdup(buf[3]);
|
||||
if (*buf[4])
|
||||
{
|
||||
free(entry->crc32);
|
||||
entry->crc32 = strdup(buf[4]);
|
||||
}
|
||||
if (*buf[5])
|
||||
{
|
||||
free(entry->db_name);
|
||||
entry->db_name = strdup(buf[5]);
|
||||
}
|
||||
playlist->size++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user