Fixed a resource leak.

This commit is contained in:
Armin Novak 2015-06-24 09:29:13 +02:00
parent 6698e24228
commit f177430acc
1 changed files with 7 additions and 1 deletions

View File

@ -91,12 +91,18 @@ int IniFile_Load_File(wIniFile* ini, const char* filename)
ini->buffer = (char*) malloc(fileSize + 2);
if (!ini->buffer)
{
fclose(ini->fp);
ini->fp = NULL;
return -1;
}
if (fread(ini->buffer, fileSize, 1, ini->fp) != 1)
{
free(ini->buffer);
fclose(ini->fp);
ini->buffer = NULL;
ini->fp = NULL;
return -1;
}
@ -107,7 +113,7 @@ int IniFile_Load_File(wIniFile* ini, const char* filename)
ini->buffer[fileSize + 1] = '\0';
ini->nextLine = strtok(ini->buffer, "\n");
return 1;
}