Fix: some memory leaks

This commit is contained in:
jcorporation 2019-01-24 00:37:04 +01:00
parent 33c490a1d7
commit f21e96444f
3 changed files with 21 additions and 3 deletions

View File

@ -295,5 +295,6 @@ int main(int argc, char **argv) {
tiny_queue_free(web_server_queue);
tiny_queue_free(mpd_client_queue);
tiny_queue_free(mympd_api_queue);
return EXIT_SUCCESS;
}

View File

@ -105,7 +105,7 @@ typedef struct t_mpd_state {
//mympd states
enum jukebox_modes jukeboxMode;
const char *jukeboxPlaylist;
char *jukeboxPlaylist;
int jukeboxQueueLength;
bool autoPlay;
@ -218,7 +218,7 @@ void *mpd_client_loop(void *arg_config) {
list_free(&mpd_state.mympd_searchtags);
list_free(&mpd_state.mympd_browsetags);
list_free(&mpd_state.last_played);
free(mpd_state.jukeboxPlaylist);
return NULL;
}
@ -1122,6 +1122,7 @@ static void mpd_client_idle(t_config *config, t_mpd_state *mpd_state) {
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"disconnected\"}");
mpd_client_notify(buffer, len);
mpd_state->conn_state = MPD_FAILURE;
sleep(3);
return;
}
@ -1130,6 +1131,7 @@ static void mpd_client_idle(t_config *config, t_mpd_state *mpd_state) {
len = snprintf(buffer, MAX_SIZE, "{\"type\": \"error\", \"data\": \"%s\"}", mpd_connection_get_error_message(mpd_state->conn));
mpd_client_notify(buffer, len);
mpd_state->conn_state = MPD_FAILURE;
sleep(3);
return;
}
@ -2820,6 +2822,10 @@ static bool mpd_client_smartpls_update_sticker(t_mpd_state *mpd_state, const cha
while ((pair = mpd_recv_pair(mpd_state->conn)) != NULL) {
if (strcmp(pair->name, "file") == 0) {
if (uri != NULL) {
free(uri);
uri = NULL;
}
uri = strdup(pair->value);
}
else if (strcmp(pair->name, "sticker") == 0) {
@ -2837,7 +2843,10 @@ static bool mpd_client_smartpls_update_sticker(t_mpd_state *mpd_state, const cha
mpd_return_pair(mpd_state->conn, pair);
}
mpd_response_finish(mpd_state->conn);
free(uri);
if (uri != NULL) {
free(uri);
uri = NULL;
}
mpd_client_smartpls_clear(mpd_state, playlist);

View File

@ -107,6 +107,14 @@ void *mympd_api_loop(void *arg_config) {
}
list_free(&mympd_state.syscmd_list);
free(mympd_state.jukeboxPlaylist);
free(mympd_state.colsQueueCurrent);
free(mympd_state.colsSearch);
free(mympd_state.colsBrowseDatabase);
free(mympd_state.colsBrowsePlaylistsDetail);
free(mympd_state.colsBrowseFilesystem);
free(mympd_state.colsPlayback);
free(mympd_state.colsQueueLastPlayed);
return NULL;
}