Commit 7d9316a5 authored by Max Kellermann's avatar Max Kellermann

song_save: don't call tag_free(NULL)

When a song was in the database twice (which shouldn't happen), and the first song had no tag items, MPD calledd tag_free(NULL). Add a check to that source location, and an assertion to tag_free().
parent fd09a3cf
......@@ -80,7 +80,8 @@ insertSongIntoList(struct songvec *sv, struct song *newsong)
tag_end_add(newsong->tag);
} else { /* prevent dupes, just update the existing song info */
if (existing->mtime != newsong->mtime) {
tag_free(existing->tag);
if (existing->tag != NULL)
tag_free(existing->tag);
if (newsong->tag)
tag_end_add(newsong->tag);
existing->tag = newsong->tag;
......
......@@ -163,6 +163,8 @@ void tag_free(struct tag *tag)
{
int i;
assert(tag != NULL);
g_mutex_lock(tag_pool_lock);
for (i = tag->num_items; --i >= 0; )
tag_pool_put_item(tag->items[i]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment