// 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();