From b2d36921d551c63c612e2926b38dd09d55c36dea Mon Sep 17 00:00:00 2001 From: pk910 Date: Thu, 10 Nov 2011 02:10:42 +0100 Subject: [PATCH] added some missing fclose --- src/ConfigParser.c | 12 ++++++++++-- src/cmd_global_motd.c | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ConfigParser.c b/src/ConfigParser.c index 775e062..061e248 100644 --- a/src/ConfigParser.c +++ b/src/ConfigParser.c @@ -46,13 +46,21 @@ int loadConfig(const char *filename) { // allocate memory to contain the whole file: char *buffer = (char*) malloc (sizeof(char)*lSize + 1); - if (buffer == NULL) return 0; + if (buffer == NULL) { + fclose(f); + return 0; + } // copy the file into the buffer: size_t result = fread (buffer, 1, lSize, f); - if (result != lSize) return 0; + if (result != lSize) { + fclose(f); + return 0; + } buffer[lSize] = '\0'; + fclose(f); + // now parse the config file... if(root_entry) { free_loaded_config(); diff --git a/src/cmd_global_motd.c b/src/cmd_global_motd.c index 275b366..ad5f8c9 100644 --- a/src/cmd_global_motd.c +++ b/src/cmd_global_motd.c @@ -31,4 +31,5 @@ CMD_BIND(global_cmd_motd) { *a = '\0'; reply(getTextBot(), user, "%s", line); } + fclose(f); } \ No newline at end of file -- 2.20.1