summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 75348aa)
raw | patch | inline | side by side (parent: 75348aa)
author | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 10:29:15 +0000 (12:29 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 17 Sep 2008 10:29:15 +0000 (12:29 +0200) |
playlist_remove_reuse() removes a song from the playlist, but does not
free it.
Use this function in mpdclient_cmd_delete() to fix a segmentation
fault: the song pointer was still used after it was freed, by passing
it to mpdclient_playlist_callback(). Free the song manually now.
Reorganize and simply some code in mpdclient_cmd_delete().
free it.
Use this function in mpdclient_cmd_delete() to fix a segmentation
fault: the song pointer was still used after it was freed, by passing
it to mpdclient_playlist_callback(). Free the song manually now.
Reorganize and simply some code in mpdclient_cmd_delete().
src/mpdclient.c | patch | blob | history | |
src/playlist.h | patch | blob | history |
diff --git a/src/mpdclient.c b/src/mpdclient.c
index f67b09133949ff0efcb78eda00b384de699214c9..469c794c61a977b87b1b538abd8507936306ca17 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
c->playlist.id++;
/* remove the song from the playlist */
- playlist_remove(&c->playlist, idx);
+ playlist_remove_reuse(&c->playlist, idx);
/* call playlist updated callback */
mpdclient_playlist_callback(c, PLAYLIST_EVENT_DELETE, (gpointer) song);
c->need_update = TRUE;
}
+ mpd_freeSong(song);
+
#else
c->need_update = TRUE;
#endif
diff --git a/src/playlist.h b/src/playlist.h
index 9cd88ab27c49c0cf84a68540f74899c680182f28..93c034f5a1361926090224d3025a3dfaa0ef7d8b 100644 (file)
--- a/src/playlist.h
+++ b/src/playlist.h
playlist_set(playlist, idx, song);
}
+static inline struct mpd_song *
+playlist_remove_reuse(struct mpdclient_playlist *playlist, guint idx)
+{
+ return g_ptr_array_remove_index(playlist->list, idx);
+}
+
static inline void
playlist_remove(struct mpdclient_playlist *playlist, guint idx)
{
- mpd_Song *song = g_ptr_array_remove_index(playlist->list, idx);
- mpd_freeSong(song);
+ mpd_freeSong(playlist_remove_reuse(playlist, idx));
}
static inline void