From 83a6c28b9e1531237dc504429d931fa7bf41d99d Mon Sep 17 00:00:00 2001 From: oetiker Date: Tue, 11 Aug 2009 14:00:57 +0000 Subject: [PATCH] fix freeing order when generating error messages. found by Dmitry V. Krivenok git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3/program@1889 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_restore.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/rrd_restore.c b/src/rrd_restore.c index 6acfa4e..c5cbcd2 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -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); -- 2.30.2