mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 03:12:00 -04:00
fix loading lumps with -file command (#1357)
Sometimes the `FileContainsMaps` function tries to allocate too much memory. * add checks for "IWAD" and "PWAD"
This commit is contained in:
parent
fc9731ffa0
commit
8b487b1ced
15
src/d_main.c
15
src/d_main.c
@ -864,9 +864,12 @@ static void CheckIWAD(const char *iwadname)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strncmp(header.identification, "IWAD", 4))
|
||||
if (strncmp(header.identification, "IWAD", 4) ||
|
||||
strncmp(header.identification, "PWAD", 4))
|
||||
{
|
||||
I_Printf(VB_WARNING, "CheckIWAD: IWAD tag not present %s", iwadname);
|
||||
fclose(file);
|
||||
I_Error("Wad file %s doesn't have IWAD or PWAD id\n", iwadname);
|
||||
return;
|
||||
}
|
||||
|
||||
// read IWAD directory
|
||||
@ -937,7 +940,7 @@ static boolean FileContainsMaps(const char *filename)
|
||||
|
||||
while (ret == false)
|
||||
{
|
||||
if (filename == NULL)
|
||||
if (filename == NULL || M_StringCaseEndsWith(filename, ".wad") == false)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@ -954,6 +957,12 @@ static boolean FileContainsMaps(const char *filename)
|
||||
break;
|
||||
}
|
||||
|
||||
if (strncmp(header.identification, "IWAD", 4) ||
|
||||
strncmp(header.identification, "PWAD", 4))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
header.numlumps = LONG(header.numlumps);
|
||||
header.infotableofs = LONG(header.infotableofs);
|
||||
fileinfo = malloc(header.numlumps * sizeof(filelump_t));
|
||||
|
Loading…
x
Reference in New Issue
Block a user