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().
This commit is contained in:
Max Kellermann 2009-04-28 19:57:49 +02:00
parent fd09a3cf1f
commit 7d9316a52d
2 changed files with 4 additions and 1 deletions

View File

@ -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;

View File

@ -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]);