]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
src/rrd_first.c: fix Coverity CID#26528 Resource leak
authorMarek Schimara <Marek.Schimara@bull.net>
Thu, 16 Jun 2016 11:23:39 +0000 (13:23 +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_first.c

index d3c31c365977ee561d09a62ca14f909b94391d93..2c68f4796489207df0d5097df906895baf43613f 100644 (file)
@@ -33,6 +33,7 @@ time_t rrd_first(
             target_rraindex = strtol(options.optarg, &endptr, 0);
             if (target_rraindex < 0) {
                 rrd_set_error("invalid rraindex number");
+                if (opt_daemon != NULL) free (opt_daemon);
                 return (-1);
             }
             break;
@@ -48,6 +49,7 @@ time_t rrd_first(
             break;
         case '?':
             rrd_set_error("%s", options.errmsg);
+            if (opt_daemon != NULL) free (opt_daemon);
             return -1;
         }
     }
@@ -55,13 +57,16 @@ time_t rrd_first(
     if (options.optind >= options.argc) {
         rrd_set_error("usage rrdtool %s [--rraindex number] [--daemon|-d <addr>] file.rrd",
                       options.argv[0]);
+        if (opt_daemon != NULL) free (opt_daemon);
         return -1;
     }
 
     rrdc_connect (opt_daemon);
     if (rrdc_is_connected (opt_daemon)) {
+      if (opt_daemon != NULL) free (opt_daemon);
       return rrdc_first(options.argv[options.optind], target_rraindex);
     } else {
+      if (opt_daemon != NULL) free (opt_daemon);
       return rrd_first_r(options.argv[options.optind], target_rraindex);
        }
 }