prepare for the release of rrdtool-1.2.21
[rrdtool.git] / src / rrd_first.c
index 518cbd3..9de89e9 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.2rc8  Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.21  Copyright by Tobi Oetiker, 1997-2007
  *****************************************************************************
  * rrd_first Return
  *****************************************************************************
@@ -14,6 +14,7 @@ rrd_first(int argc, char **argv)
 {
     int target_rraindex=0;
     char *endptr;
+    optind = 0; opterr = 0;  /* initialize getopt */
 
     while (1){
         static struct option long_options[] =
@@ -67,6 +68,8 @@ rrd_first_r(const char *filename, const int rraindex)
 
     if((rraindex < 0) || (rraindex >= (int)rrd.stat_head->rra_cnt)) {
         rrd_set_error("invalid rraindex number");
+        rrd_free(&rrd);
+        fclose(in_file);
         return(-1);
     }