From 14621d9b1493e22713dfe9259da549c3ab911f98 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 4 Mar 2001 10:29:20 +0000 Subject: [PATCH] fixed filedescriptor leak -- Mike Franusich git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@19 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_open.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c index 36bc8758..1a3496d4 100644 --- a/program/src/rrd_open.c +++ b/program/src/rrd_open.c @@ -5,8 +5,12 @@ ***************************************************************************** * $Id$ * $Log$ - * Revision 1.1 2001/02/25 22:25:05 oetiker - * Initial revision + * Revision 1.2 2001/03/04 10:29:20 oetiker + * fixed filedescriptor leak + * -- Mike Franusich + * + * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker + * checkin * *****************************************************************************/ @@ -45,6 +49,7 @@ rrd_open(char *file_name, FILE **in_file, rrd_t *rrd, int rdwr) #define MYFREAD(MYVAR,MYVART,MYCNT) \ if ((MYVAR = malloc(sizeof(MYVART) * MYCNT)) == NULL) {\ rrd_set_error("" #MYVAR " malloc"); \ + fclose(*in_file); \ return (-1); } \ fread(MYVAR,sizeof(MYVART),MYCNT, *in_file); @@ -55,17 +60,20 @@ rrd_open(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); + fclose(*in_file); return(-1);} if (strncmp(rrd->stat_head->version,RRD_VERSION,5) != 0){ - rrd_set_error("cant handle RRD file version %s", + rrd_set_error("can't handle RRD file version %s", rrd->stat_head->version); free(rrd->stat_head); + 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); + fclose(*in_file); return(-1);} MYFREAD(rrd->ds_def, ds_def_t, rrd->stat_head->ds_cnt) -- 2.30.2