From d0a7578e52cbe8b6222cc2ef48273322db963205 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 19 Jun 2015 10:54:02 +0200 Subject: [PATCH] gmond plugin: Fix memory leak. --- src/gmond.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gmond.c b/src/gmond.c index ff4936d1..7c9028a1 100644 --- a/src/gmond.c +++ b/src/gmond.c @@ -217,13 +217,13 @@ static int create_sockets (socket_entry_t **ret_sockets, /* {{{ */ struct addrinfo *ai_ptr; int ai_return; - socket_entry_t *sockets; - size_t sockets_num; + socket_entry_t *sockets = NULL; + size_t sockets_num = 0; int status; - - sockets = *ret_sockets; - sockets_num = *ret_sockets_num; + + if (*ret_sockets != NULL) + return (EINVAL); memset (&ai_hints, 0, sizeof (ai_hints)); ai_hints.ai_flags = 0; @@ -355,8 +355,11 @@ static int create_sockets (socket_entry_t **ret_sockets, /* {{{ */ freeaddrinfo (ai_list); - if ((*ret_sockets_num) >= sockets_num) + if (sockets_num == 0) + { + sfree (sockets); return (-1); + } *ret_sockets = sockets; *ret_sockets_num = sockets_num; -- 2.30.2