prepare for the release of rrdtool-1.2.13
[rrdtool.git] / src / rrd_restore.c
index 3246047..51def7e 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * RRDtool 1.2.12  Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.13  Copyright by Tobi Oetiker, 1997-2006
  *****************************************************************************
  * rrd_restore.c  creates new rrd from data dumped by rrd_dump.c
  *****************************************************************************/
@@ -130,10 +130,12 @@ int xml2rrd(char* buf, rrd_t* rrd, char rc){
   read_tag(&ptr,"version","%4[0-9]",rrd->stat_head->version);
   input_version = atoi(rrd->stat_head->version);
   /* added primitive version checking */
-  if (input_version > atoi(RRD_VERSION) )
+  if (input_version > atoi(RRD_VERSION) || input_version < 1)
   {
-    rrd_set_error("Incompatible file version, detected version %s is bigger than supported version %s\n",
+    rrd_set_error("Incompatible file version, detected version %s. This is not supported by the version %s restore tool.\n",
                  rrd -> stat_head -> version, RRD_VERSION );
+    free(rrd -> stat_head); 
+    rrd->stat_head = NULL; 
     return -1;
   }
   /* make sure we output the right version */