From c587a120d027a8fc32b806a737bb74790411b520 Mon Sep 17 00:00:00 2001 From: jcorporation Date: Mon, 28 Jan 2019 20:49:46 +0100 Subject: [PATCH] Fix: memory leaks reported by valingrid --- src/mpd_client.c | 2 ++ src/mympd_api.c | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mpd_client.c b/src/mpd_client.c index e0cc704..9a66f9d 100644 --- a/src/mpd_client.c +++ b/src/mpd_client.c @@ -822,6 +822,7 @@ static void mpd_client_api(t_config *config, t_mpd_state *mpd_state, void *arg_r len = mpd_client_search(config, mpd_state, buffer, p_charbuf1, p_charbuf2, p_charbuf3, uint_buf1); free(p_charbuf1); free(p_charbuf2); + free(p_charbuf3); } break; case MPD_API_DATABASE_SEARCH_ADV: @@ -2656,6 +2657,7 @@ static int mpd_client_smartpls_put(t_config *config, char *buffer, const char *p len = json_printf(&out, "{type: error, data: %Q}}", "Unknown smart playlist type"); printf("Unknown smart playlist type: %s\n", pl_file); } + free(content); return len; } diff --git a/src/mympd_api.c b/src/mympd_api.c index 06b3419..3c3bd1e 100644 --- a/src/mympd_api.c +++ b/src/mympd_api.c @@ -275,13 +275,17 @@ static bool mympd_api_read_syscmds(t_config *config, t_mympd_state *mympd_state) if (strncmp(ent->d_name, ".", 1) == 0) continue; order = strtol(ent->d_name, &cmd, 10); - if (strcmp(cmd, "") != 0) - list_push(&mympd_state->syscmd_list, strdup(cmd), order); + if (strcmp(cmd, "") != 0) { + list_push(&mympd_state->syscmd_list, cmd, order); + } + else { + printf("ERROR: Can't read syscmd file %s\n", ent->d_name); + } } closedir(dir); } else { - printf("ERROR: Can't read syscmds"); + printf("ERROR: Can't read syscmds\n"); } } else {