summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a094e91)
raw | patch | inline | side by side (parent: a094e91)
author | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:51:45 +0000 (21:51 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:51:45 +0000 (21:51 +0100) |
Don't store a pointer to the song passed to screen_lyrics_switch(),
duplicate it instead. In the long term, it is too unsafe to work with
a foreign pointer.
duplicate it instead. In the long term, it is too unsafe to work with
a foreign pointer.
src/screen_lyrics.c | patch | blob | history |
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index f98e6692b817f192d8f1cbfefa2e311ffad53760..ab9dfdedaefbaf9c0f3b8faa830279eb799b907c 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
static const struct mpd_song *next_song;
static struct {
- const struct mpd_song *song;
+ struct mpd_song *song;
char *artist, *title;
current.artist = NULL;
}
- current.song = NULL;
+ if (current.song != NULL) {
+ mpd_freeSong(current.song);
+ current.song = NULL;
+ }
}
static void
screen_lyrics_abort();
screen_lyrics_clear();
- current.song = song;
+ current.song = mpd_songDup(song);
strfsong(buffer, sizeof(buffer), "%artist%", song);
current.artist = g_strdup(buffer);
if (next_song == NULL)
next_song = c->song;
- if (next_song != NULL && next_song != current.song)
+ if (next_song != NULL &&
+ (current.song == NULL ||
+ strcmp(next_song->file, current.song->file) != 0))
screen_lyrics_load(next_song);
next_song = NULL;