From 5c7db5abef470bc6a0f2e3858a5fc75731c9f3bd Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Thu, 17 Jan 2008 17:16:54 +0000 Subject: Max Kellermann : fix memory leaks in several error output paths --- ChangeLog | 1 + src/mcast.c | 4 ++++ src/stats-mode.c | 3 +++ src/sync-mode.c | 3 +++ 4 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3d53d51..e9a6b5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -76,6 +76,7 @@ o chdir("/") to release the cwd inode o ignore setsid() failure, because there is only one possible and o fix harmless error condition o add buffer_destroy() to buffer.c +o fix memory leaks in several error output paths version 0.9.5 (2007/07/29) ------------------------------ diff --git a/src/mcast.c b/src/mcast.c index 185a7e2..9684b61 100644 --- a/src/mcast.c +++ b/src/mcast.c @@ -80,6 +80,8 @@ struct mcast_sock *mcast_server_create(struct mcast_conf *conf) if (ioctl(m->fd, SIOCGIFMTU, &ifr) == -1) { debug("ioctl"); + close(m->fd); + free(m); return NULL; } conf->mtu = ifr.ifr_mtu; @@ -201,6 +203,7 @@ struct mcast_sock *mcast_client_create(struct mcast_conf *conf) if ((m->fd = socket(conf->ipproto, SOCK_DGRAM, 0)) == -1) { debug("mcast_sock_client_create:socket"); + free(m); return NULL; } @@ -224,6 +227,7 @@ struct mcast_sock *mcast_client_create(struct mcast_conf *conf) } if (ret == -1) { + close(m->fd); free(m); m = NULL; } diff --git a/src/stats-mode.c b/src/stats-mode.c index 563e1f6..0c42d95 100644 --- a/src/stats-mode.c +++ b/src/stats-mode.c @@ -41,6 +41,7 @@ static int init_stats(void) STATE_STATS(buffer_log) = buffer_create(CONFIG(stats).buffer_size); if (!STATE_STATS(buffer_log)) { dlog(STATE(log), LOG_ERR, "can't allocate stats buffer"); + free(state.stats); return -1; } @@ -51,6 +52,8 @@ static int init_stats(void) if (!STATE_STATS(cache)) { dlog(STATE(log), LOG_ERR, "can't allocate memory for the " "external cache"); + free(state.stats); + buffer_destroy(STATE_STATS(buffer_log)); return -1; } diff --git a/src/sync-mode.c b/src/sync-mode.c index f2bfc9f..1632019 100644 --- a/src/sync-mode.c +++ b/src/sync-mode.c @@ -180,11 +180,14 @@ static int init_sync(void) STATE_SYNC(mcast_client) = mcast_client_create(&CONFIG(mcast)); if (STATE_SYNC(mcast_client) == NULL) { dlog(STATE(log), LOG_ERR, "can't open client multicast socket"); + mcast_server_destroy(STATE_SYNC(mcast_server)); return -1; } if (mcast_buffered_init(&CONFIG(mcast)) == -1) { dlog(STATE(log), LOG_ERR, "can't init tx buffer!"); + mcast_server_destroy(STATE_SYNC(mcast_server)); + mcast_client_destroy(STATE_SYNC(mcast_client)); return -1; } -- cgit v1.2.3