Another year is about to end... So we have to update these damn copyright information :P
[NeonServV5.git] / src / ConfigParser.c
index 775e062fef399dc4385bd2c06e3e9499d9a48cb1..8ce6cde088e3758123259395873bc9a522510bee 100644 (file)
@@ -1,5 +1,5 @@
-/* ConfigParser.c - NeonServ v5.2
- * Copyright (C) 2011  Philipp Kreil (pk910)
+/* ConfigParser.c - NeonServ v5.3
+ * Copyright (C) 2011-2012  Philipp Kreil (pk910)
  * 
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -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();