summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5b4b598)
raw | patch | inline | side by side (parent: 5b4b598)
author | Max Kellermann <max@duempel.org> | |
Fri, 18 Sep 2009 09:30:49 +0000 (11:30 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Fri, 18 Sep 2009 09:30:49 +0000 (11:30 +0200) |
The screen_X_switch() function calls screen_switch. As a side effect
of the previous screen being closed, the next_song pointer may become
invalid, which causes memory corruption. Let's duplicate the song
when assigning it to next_song.
of the previous screen being closed, the next_song pointer may become
invalid, which causes memory corruption. Let's duplicate the song
when assigning it to next_song.
src/screen_lyrics.c | patch | blob | history | |
src/screen_song.c | patch | blob | history |
diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c
index a1556aec582bbdf2cf2d2eb3ad9d013a41b3b812..8f7c23d4436448c3950e4cb46e26a0e91580ed42 100644 (file)
--- a/src/screen_lyrics.c
+++ b/src/screen_lyrics.c
static struct screen_text text;
-static const struct mpd_song *next_song;
+static struct mpd_song *next_song;
static bool follow = false;
static struct {
strcmp(next_song->file, current.song->file) != 0))
screen_lyrics_load(next_song);
+ if (next_song != c->song)
+ mpd_freeSong(next_song);
next_song = NULL;
}
assert(song != NULL);
follow = f;
- next_song = song;
+ next_song = mpd_songDup(song);
screen_switch(&screen_lyrics, c);
}
diff --git a/src/screen_song.c b/src/screen_song.c
index 6d27e564a6ca8a23811f42f2f1986839cfdf493e..a7d6f8ee4c087c4dbdae4b189c4c528465bd7985 100644 (file)
--- a/src/screen_song.c
+++ b/src/screen_song.c
static list_window_t *lw;
-static const struct mpd_song *next_song;
+static struct mpd_song *next_song;
static struct {
struct mpd_song *selected_song;
/* If a song was selected before the song screen was opened */
if (next_song != NULL) {
assert(current.selected_song == NULL);
- current.selected_song = mpd_songDup(next_song);
+ current.selected_song = next_song;
next_song = NULL;
}
assert(current.selected_song == NULL);
assert(current.played_song == NULL);
- next_song = song;
+ next_song = mpd_songDup(song);
screen_switch(&screen_song, c);
}