From 5e060d8a49301fee5681969c8771473dd024cb98 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sat, 14 May 2005 15:07:35 +0000 Subject: [PATCH] check cookie read for success git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@557 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_open.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/rrd_open.c b/src/rrd_open.c index ff68ca4..7b1a0f1 100644 --- a/src/rrd_open.c +++ b/src/rrd_open.c @@ -101,11 +101,17 @@ rrd_open(const char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) if ((MYVAR = malloc(sizeof(MYVART) * MYCNT)) == NULL) {\ rrd_set_error("" #MYVAR " malloc"); \ fclose(*in_file); \ - return (-1); } \ + return (-1); } \ fread(MYVAR,sizeof(MYVART),MYCNT, *in_file); MYFREAD(rrd->stat_head, stat_head_t, 1) + /* lets see if the first read worked */ + if (ferror( *in_file )){ + rrd_set_error("reading the cookie off %s faild",file_name); + fclose(*in_file); + return(-1); + } version = atoi(rrd->stat_head->version); /* lets do some test if we are on track ... */ -- 2.30.2