]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_info.c: fix Coverity CID#26535 Resource leak
authorMarek Schimara <Marek.Schimara@bull.net>
Thu, 16 Jun 2016 09:16:48 +0000 (11:16 +0200)
committerMarek Schimara <Marek.Schimara@bull.net>
Thu, 23 Jun 2016 14:32:33 +0000 (16:32 +0200)
        CWE-404 / https://cwe.mitre.org/data/definitions/404.html

src/rrd_info.c

index 015cc19a23449f958d961a5ef901c7d3e818688f..da60ef32eaf9f66db7480502aa99589819699f85 100644 (file)
@@ -120,6 +120,7 @@ rrd_info_t *rrd_info(
 
         case '?':
             rrd_set_error("%s", options.errmsg);
+            if (opt_daemon) free (opt_daemon);
             return NULL;
         }
     } /* while (opt != -1) */
@@ -127,12 +128,16 @@ rrd_info_t *rrd_info(
     if (options.argc - options.optind != 1) {
         rrd_set_error ("Usage: rrdtool %s [--daemon |-d <addr> [--noflush|-F]] <file>",
                 options.argv[0]);
+        if (opt_daemon) free (opt_daemon);
         return NULL;
     }
 
     if (flushfirst) {
         status = rrdc_flush_if_daemon(opt_daemon, options.argv[options.optind]);
-        if (status) return (NULL);
+        if (status) {
+            if (opt_daemon) free (opt_daemon);
+            return (NULL);
+        }
     }
 
     rrdc_connect (opt_daemon);