Fix memory leak due to missing free for evconnlistener

This commit is contained in:
chme 2015-09-19 09:35:27 +02:00 committed by ejurgensen
parent 6c26d87997
commit 1ed240d92c
1 changed files with 5 additions and 1 deletions

View File

@ -71,6 +71,8 @@ static struct event *g_cmdev;
static struct evhttp *evhttpd; static struct evhttp *evhttpd;
struct evconnlistener *listener;
struct mpd_command; struct mpd_command;
typedef int (*cmd_func)(struct mpd_command *cmd); typedef int (*cmd_func)(struct mpd_command *cmd);
@ -4394,7 +4396,6 @@ artwork_cb(struct evhttp_request *req, void *arg)
/* Thread: main */ /* Thread: main */
int mpd_init(void) int mpd_init(void)
{ {
struct evconnlistener *listener;
struct sockaddr *saddr; struct sockaddr *saddr;
size_t saddr_length; size_t saddr_length;
struct sockaddr_in sin; struct sockaddr_in sin;
@ -4546,6 +4547,7 @@ int mpd_init(void)
if (http_port > 0) if (http_port > 0)
evhttp_free(evhttpd); evhttp_free(evhttpd);
evhttp_fail: evhttp_fail:
evconnlistener_free(listener);
connew_fail: connew_fail:
evnew_fail: evnew_fail:
event_base_free(evbase_mpd); event_base_free(evbase_mpd);
@ -4600,6 +4602,8 @@ void mpd_deinit(void)
if (http_port > 0) if (http_port > 0)
evhttp_free(evhttpd); evhttp_free(evhttpd);
evconnlistener_free(listener);
// Free event base (should free events too) // Free event base (should free events too)
event_base_free(evbase_mpd); event_base_free(evbase_mpd);