From b01e650546075f574068d89eb58101a88a8f5ed2 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 31 Jul 2010 18:12:48 +0200 Subject: Fix genre station NULL pointer dereference Obviously pandora changed the genre station api. Attention: Incompatible libpiano abi change. --- libpiano/src/piano.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'libpiano/src/piano.c') diff --git a/libpiano/src/piano.c b/libpiano/src/piano.c index d8b40de..8682cda 100644 --- a/libpiano/src/piano.c +++ b/libpiano/src/piano.c @@ -150,6 +150,21 @@ void PianoDestroyPlaylist (PianoSong_t *playlist) { } } +/* destroy genre linked list + */ +void PianoDestroyGenres (PianoGenre_t *genres) { + PianoGenre_t *curGenre, *lastGenre; + + curGenre = genres; + while (curGenre != NULL) { + PianoFree (curGenre->name, 0); + PianoFree (curGenre->musicId, 0); + lastGenre = curGenre; + curGenre = curGenre->next; + PianoFree (lastGenre, sizeof (*lastGenre)); + } +} + /* frees the whole piano handle structure * @param piano handle * @return nothing @@ -163,7 +178,7 @@ void PianoDestroy (PianoHandle_t *ph) { /* destroy genre stations */ PianoGenreCategory_t *curGenreCat = ph->genreStations, *lastGenreCat; while (curGenreCat != NULL) { - PianoDestroyStations (curGenreCat->stations); + PianoDestroyGenres (curGenreCat->genres); PianoFree (curGenreCat->name, 0); lastGenreCat = curGenreCat; curGenreCat = curGenreCat->next; -- cgit v1.2.3