diff options
author | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-10-25 12:12:12 +0200 |
---|---|---|
committer | Lars-Dominik Braun <PromyLOPh@lavabit.com> | 2010-10-28 13:08:10 +0200 |
commit | 35e71bcb76b702a8b67fd556083c5df50273fe4c (patch) | |
tree | 4b1a8c224e9757f48d4103fb790926646584a5f8 /libpiano/src/piano.c | |
parent | 3a2e42b0cd164c0d52805b539353c5b12492e284 (diff) | |
download | pianobar-35e71bcb76b702a8b67fd556083c5df50273fe4c.tar.gz pianobar-35e71bcb76b702a8b67fd556083c5df50273fe4c.tar.bz2 pianobar-35e71bcb76b702a8b67fd556083c5df50273fe4c.zip |
piano: Destroy existing user info on reauth
Diffstat (limited to 'libpiano/src/piano.c')
-rw-r--r-- | libpiano/src/piano.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/libpiano/src/piano.c b/libpiano/src/piano.c index 4354fa6..1d63e8e 100644 --- a/libpiano/src/piano.c +++ b/libpiano/src/piano.c @@ -164,15 +164,20 @@ void PianoDestroyGenres (PianoGenre_t *genres) { } } +/* destroy user information + */ +void PianoDestroyUserInfo (PianoUserInfo_t *user) { + PianoFree (user->webAuthToken, 0); + PianoFree (user->authToken, 0); + PianoFree (user->listenerId, 0); +} + /* frees the whole piano handle structure * @param piano handle * @return nothing */ void PianoDestroy (PianoHandle_t *ph) { - PianoFree (ph->user.webAuthToken, 0); - PianoFree (ph->user.authToken, 0); - PianoFree (ph->user.listenerId, 0); - + PianoDestroyUserInfo (&ph->user); PianoDestroyStations (ph->stations); /* destroy genre stations */ PianoGenreCategory_t *curGenreCat = ph->genreStations, *lastGenreCat; @@ -796,6 +801,11 @@ PianoReturn_t PianoResponse (PianoHandle_t *ph, PianoRequest_t *req) { } case 1: + /* information exists when reauthenticating, destroy to + * avoid memleak */ + if (ph->user.listenerId != NULL) { + PianoDestroyUserInfo (&ph->user); + } ret = PianoXmlParseUserinfo (ph, req->responseData); break; } |