From: Marek Schimara Date: Wed, 15 Jun 2016 09:09:34 +0000 (+0200) Subject: src/rrd_daemon.c: fix Coverity CIDs#32420,#26530 Resource leak X-Git-Tag: v1.7.0~42^2~55 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c83915732c4655d121cc9d97cfaa7b3fdcd8c6eb;p=thirdparty%2Frrdtool-1.x.git src/rrd_daemon.c: fix Coverity CIDs#32420,#26530 Resource leak CWE-404 / https://cwe.mitre.org/data/definitions/404.html --- diff --git a/src/rrd_daemon.c b/src/rrd_daemon.c index b1a7c599..32d8a240 100644 --- a/src/rrd_daemon.c +++ b/src/rrd_daemon.c @@ -3279,20 +3279,21 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ } dir = strdup(dirname(path_copy)); + free(path_copy); if (rrd_mkdir_p(dir, 0777) != 0) { fprintf(stderr, "Failed to create socket directory '%s': %s\n", dir, rrd_strerror(errno)); + free(dir); return (-1); } - free(path_copy); - temp = (listen_socket_t *) rrd_realloc (listen_fds, sizeof (listen_fds[0]) * (listen_fds_num + 1)); if (temp == NULL) { fprintf (stderr, "rrdcached: open_listen_socket_unix: realloc failed.\n"); + free(dir); return (-1); } listen_fds = temp; @@ -3303,6 +3304,7 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ { fprintf (stderr, "rrdcached: unix socket(2) failed: %s\n", rrd_strerror(errno)); + free(dir); return (-1); } @@ -3322,6 +3324,7 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ fprintf (stderr, "rrdcached: bind(%s) failed: %s.\n", path, rrd_strerror(errno)); close (fd); + free(dir); return (-1); } @@ -3349,6 +3352,7 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ path, rrd_strerror(errno)); close (fd); unlink (path); + free(dir); return (-1); } @@ -3357,6 +3361,7 @@ static int open_listen_socket_unix (const listen_socket_t *sock) /* {{{ */ listen_fds[listen_fds_num].addr = strdup(path); listen_fds_num++; + free(dir); return (0); } /* }}} int open_listen_socket_unix */