added some missing fclose
authorpk910 <philipp@zoelle1.de>
Thu, 10 Nov 2011 01:10:42 +0000 (02:10 +0100)
committerpk910 <philipp@zoelle1.de>
Thu, 10 Nov 2011 01:10:42 +0000 (02:10 +0100)
src/ConfigParser.c
src/cmd_global_motd.c

index 775e062fef399dc4385bd2c06e3e9499d9a48cb1..061e2488d34d35c7fd66bf21c09292dd42554572 100644 (file)
@@ -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();
index 275b3669de89511c163c11d34be8bc719d07bcc3..ad5f8c97d9c0fa3ff1c085ce137c0384bbac0371 100644 (file)
@@ -31,4 +31,5 @@ CMD_BIND(global_cmd_motd) {
             *a = '\0';
         reply(getTextBot(), user, "%s", line);
     }
+    fclose(f);
 }
\ No newline at end of file