mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Make sure handles of files opened by W_LoadWadFile are closed if we abort loading the files for whatever reason.
ESPECIALLY if the file is already loaded in SRB2, that's just silly.
This commit is contained in:
parent
529f38d1e9
commit
a67dd8821f
1 changed files with 8 additions and 0 deletions
|
|
@ -381,6 +381,8 @@ UINT16 W_LoadWadFile(const char *filename)
|
||||||
if (fread(&header, 1, sizeof header, handle) < sizeof header)
|
if (fread(&header, 1, sizeof header, handle) < sizeof header)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header from %s because %s\n"), filename, strerror(ferror(handle)));
|
CONS_Alert(CONS_ERROR, M_GetText("Can't read wad header from %s because %s\n"), filename, strerror(ferror(handle)));
|
||||||
|
if (handle)
|
||||||
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return INT16_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,6 +393,8 @@ UINT16 W_LoadWadFile(const char *filename)
|
||||||
&& memcmp(header.identification, "SDLL", 4) != 0)
|
&& memcmp(header.identification, "SDLL", 4) != 0)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("%s does not have a valid WAD header\n"), filename);
|
CONS_Alert(CONS_ERROR, M_GetText("%s does not have a valid WAD header\n"), filename);
|
||||||
|
if (handle)
|
||||||
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return INT16_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,6 +409,8 @@ UINT16 W_LoadWadFile(const char *filename)
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("Wadfile directory in %s is corrupted (%s)\n"), filename, strerror(ferror(handle)));
|
CONS_Alert(CONS_ERROR, M_GetText("Wadfile directory in %s is corrupted (%s)\n"), filename, strerror(ferror(handle)));
|
||||||
free(fileinfov);
|
free(fileinfov);
|
||||||
|
if (handle)
|
||||||
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return INT16_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -462,6 +468,8 @@ UINT16 W_LoadWadFile(const char *filename)
|
||||||
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
|
if (!memcmp(wadfiles[i]->md5sum, md5sum, 16))
|
||||||
{
|
{
|
||||||
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename);
|
CONS_Alert(CONS_ERROR, M_GetText("%s is already loaded\n"), filename);
|
||||||
|
if (handle)
|
||||||
|
fclose(handle);
|
||||||
return INT16_MAX;
|
return INT16_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue