Code

fix freeing order when generating error messages. found by Dmitry V. Krivenok
authoroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Tue, 11 Aug 2009 14:00:57 +0000 (14:00 +0000)
committeroetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa>
Tue, 11 Aug 2009 14:00:57 +0000 (14:00 +0000)
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1889 a5681a0c-68f1-0310-ab6d-d61299d08faa

program/src/rrd_restore.c

index 6acfa4e07395be0f9bc5fefc11e6437dfb38745f..c5cbcd2dffae485242236e9bd7793dd45054a604 100644 (file)
@@ -108,14 +108,14 @@ static int get_long_from_node(
 
     end_ptr = NULL;
     temp = strtol(str_ptr, &end_ptr, 0);
-    xmlFree(str_ptr);
 
     if (str_ptr == end_ptr) {
         rrd_set_error("get_long_from_node: Cannot parse buffer as long: %s",
                       str_ptr);
+        xmlFree(str_ptr);
         return (-1);
     }
-
+    xmlFree(str_ptr);
     *value = temp;
 
     return (0);
@@ -138,14 +138,15 @@ static int get_ulong_from_node(
 
     end_ptr = NULL;
     temp = strtoul(str_ptr, &end_ptr, 0);
-    xmlFree(str_ptr);
 
     if (str_ptr == end_ptr) {
         rrd_set_error("get_ulong_from_node: Cannot parse buffer as unsigned long: %s",
                       str_ptr);
+        xmlFree(str_ptr);
         return (-1);
     }
-
+    xmlFree(str_ptr);
     *value = temp;
 
     return (0);
@@ -178,14 +179,14 @@ static int get_llong_from_node(
 
     end_ptr = NULL;
     temp = strtoll(str_ptr, &end_ptr, 10);
-    xmlFree(str_ptr);
 
     if (str_ptr == end_ptr) {
         rrd_set_error("get_llong_from_node: Cannot parse buffer as unsigned long long: %s",
                       str_ptr);
+        xmlFree(str_ptr);
         return (-1);
     }
-
+    xmlFree(str_ptr);
     *value = temp;
 
     return (0);
@@ -215,15 +216,15 @@ static int get_double_from_node(
 
     end_ptr = NULL;
     temp = strtod(str_ptr, &end_ptr);
-    xmlFree(str_ptr);
 
     if (str_ptr == end_ptr) {
         rrd_set_error
             ("get_double_from_node: Cannot parse buffer as double: %s",
              str_ptr);
+        xmlFree(str_ptr);
         return (-1);
     }
-
+    xmlFree(str_ptr);           
     *value = temp;
 
     return (0);