[PATCH] Fix potential memory leak in rrd_flushcached during failure.

View: New views
2 Messages — Rating Filter:   Alert me  

[PATCH] Fix potential memory leak in rrd_flushcached during failure.

by kevin brintnall :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

---
 src/rrd_flushcached.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/rrd_flushcached.c b/src/rrd_flushcached.c
index 5d18a1e..93b0fb5 100644
--- a/src/rrd_flushcached.c
+++ b/src/rrd_flushcached.c
@@ -74,7 +74,7 @@ int rrd_flushcached (int argc, char **argv)
 
     /* try to connect to rrdcached */
     status = rrdc_connect(opt_daemon);
-    if (status != 0) return status;
+    if (status != 0) goto out;
 
     if (! rrdc_is_connected(opt_daemon))
     {
@@ -82,7 +82,8 @@ int rrd_flushcached (int argc, char **argv)
                 "option to set an address on the command line or set the "
                 "\"%s\" environment variable.",
                 ENV_RRDCACHED_ADDRESS);
-        return (-1);
+        status = -1;
+        goto out;
     }
 
     status = 0;
@@ -106,9 +107,10 @@ int rrd_flushcached (int argc, char **argv)
         }
     }
 
+out:
     if (opt_daemon) free(opt_daemon);
 
-    return ((status == 0) ? 0 : -1);
+    return status;
 } /* int rrd_flush */
 
 /*
--
1.6.4

_______________________________________________
rrd-developers mailing list
rrd-developers@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers

Re: [PATCH] Fix potential memory leak in rrd_flushcached during failure.

by Tobias Oetiker-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Kevin,

Today kevin brintnall wrote:

> ---
>  src/rrd_flushcached.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)

thanks
tobi


--
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi@... ++41 62 775 9902 / sb: -9900

_______________________________________________
rrd-developers mailing list
rrd-developers@...
https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers