summaryrefslogtreecommitdiff
path: root/libpiano
diff options
context:
space:
mode:
authorLars-Dominik Braun <PromyLOPh@lavabit.com>2010-07-31 18:12:48 +0200
committerLars-Dominik Braun <PromyLOPh@lavabit.com>2010-07-31 18:12:48 +0200
commitb01e650546075f574068d89eb58101a88a8f5ed2 (patch)
tree1150b7ea5d147315e07efa4eae9bfd8fed500d58 /libpiano
parent1dac515822e85646c2539d2c6261a9c55b6802ab (diff)
downloadpianobar-windows-b01e650546075f574068d89eb58101a88a8f5ed2.tar.gz
pianobar-windows-b01e650546075f574068d89eb58101a88a8f5ed2.tar.bz2
pianobar-windows-b01e650546075f574068d89eb58101a88a8f5ed2.zip
Fix genre station NULL pointer dereference
Obviously pandora changed the genre station api. Attention: Incompatible libpiano abi change.
Diffstat (limited to 'libpiano')
-rw-r--r--libpiano/src/piano.c17
-rw-r--r--libpiano/src/piano.h8
-rw-r--r--libpiano/src/xml.c22
3 files changed, 34 insertions, 13 deletions
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;
diff --git a/libpiano/src/piano.h b/libpiano/src/piano.h
index fb97949..6b25b2d 100644
--- a/libpiano/src/piano.h
+++ b/libpiano/src/piano.h
@@ -87,9 +87,15 @@ typedef struct PianoArtist {
struct PianoArtist *next;
} PianoArtist_t;
+typedef struct PianoGenre {
+ char *name;
+ char *musicId;
+ struct PianoGenre *next;
+} PianoGenre_t;
+
typedef struct PianoGenreCategory {
char *name;
- PianoStation_t *stations;
+ PianoGenre_t *genres;
struct PianoGenreCategory *next;
} PianoGenreCategory_t;
diff --git a/libpiano/src/xml.c b/libpiano/src/xml.c
index 33fe557..78f7f21 100644
--- a/libpiano/src/xml.c
+++ b/libpiano/src/xml.c
@@ -745,27 +745,27 @@ PianoReturn_t PianoXmlParseGenreExplorer (PianoHandle_t *ph, char *xml) {
/* get genre subnodes */
for (genreNode = ezxml_child (catNode, "genre"); genreNode;
genreNode = genreNode->next) {
- PianoStation_t *tmpStation;
+ PianoGenre_t *tmpGenre;
- if ((tmpStation = calloc (1, sizeof (*tmpStation))) == NULL) {
+ if ((tmpGenre = calloc (1, sizeof (*tmpGenre))) == NULL) {
ezxml_free (xmlDoc);
return PIANO_RET_OUT_OF_MEMORY;
}
/* get genre attributes */
- tmpStation->name = strdup (ezxml_attr (genreNode, "name"));
- tmpStation->id = strdup (ezxml_attr (genreNode, "stationId"));
+ tmpGenre->name = strdup (ezxml_attr (genreNode, "name"));
+ tmpGenre->musicId = strdup (ezxml_attr (genreNode, "musicId"));
/* append station */
- if (tmpGenreCategory->stations == NULL) {
- tmpGenreCategory->stations = tmpStation;
+ if (tmpGenreCategory->genres == NULL) {
+ tmpGenreCategory->genres = tmpGenre;
} else {
- PianoStation_t *curStation =
- tmpGenreCategory->stations;
- while (curStation->next != NULL) {
- curStation = curStation->next;
+ PianoGenre_t *curGenre =
+ tmpGenreCategory->genres;
+ while (curGenre->next != NULL) {
+ curGenre = curGenre->next;
}
- curStation->next = tmpStation;
+ curGenre->next = tmpGenre;
}
}
/* append category */