From: oetiker Date: Thu, 4 May 2006 13:12:01 +0000 (+0000) Subject: fewer double frees ... -- slamb slamb.org X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2daf6ba2dd1b7ff8a163fd5d4461bf252f046e20;p=rrdtool-all.git fewer double frees ... -- slamb slamb.org git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@811 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_create.c b/program/src/rrd_create.c index 78979f5c..0fd96cbd 100644 --- a/program/src/rrd_create.c +++ b/program/src/rrd_create.c @@ -554,8 +554,11 @@ rrd_create_fn(char *file_name, rrd_t *rrd) if ((rrd_file = fopen(file_name,"wb")) == NULL ) { rrd_set_error("creating '%s': %s",file_name, rrd_strerror(errno)); free(rrd->stat_head); + rrd->stat_head = NULL; free(rrd->ds_def); + rrd->ds_def = NULL; free(rrd->rra_def); + rrd->rra_def = NULL; return(-1); } diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index 23914826..567ffdb8 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -117,12 +117,14 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) if (strncmp(rrd->stat_head->cookie,RRD_COOKIE,4) != 0){ rrd_set_error("'%s' is not an RRD file",file_name); free(rrd->stat_head); + rrd->stat_head = NULL; fclose(*in_file); return(-1);} if (rrd->stat_head->float_cookie != FLOAT_COOKIE){ rrd_set_error("This RRD was created on other architecture"); free(rrd->stat_head); + rrd->stat_head = NULL; fclose(*in_file); return(-1);} @@ -132,6 +134,7 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) rrd_set_error("can't handle RRD file version %s", rrd->stat_head->version); free(rrd->stat_head); + rrd->stat_head = NULL; fclose(*in_file); return(-1);} diff --git a/program/src/rrd_restore.c b/program/src/rrd_restore.c index 3246047c..a7945239 100644 --- a/program/src/rrd_restore.c +++ b/program/src/rrd_restore.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 */