properly initialize shit before attempting to read from the file

fixes load failure when attaching a debugger
This commit is contained in:
StapleButter 2018-10-18 05:14:15 +02:00
parent b5c39680a5
commit 467461fb3d

View File

@ -86,7 +86,7 @@ Savestate::Savestate(char* filename, bool save)
len = (u32)ftell(file);
fseek(file, 0, SEEK_SET);
u32 buf;
u32 buf = 0;
fread(&buf, 4, 1, file);
if (buf != ((u32*)magic)[0])
@ -96,6 +96,9 @@ Savestate::Savestate(char* filename, bool save)
return;
}
VersionMajor = 0;
VersionMinor = 0;
fread(&VersionMajor, 2, 1, file);
if (VersionMajor != SAVESTATE_MAJOR)
{
@ -107,6 +110,7 @@ Savestate::Savestate(char* filename, bool save)
fread(&VersionMinor, 2, 1, file);
// TODO: handle it???
buf = 0;
fread(&buf, 4, 1, file);
if (buf != len)
{
@ -175,7 +179,7 @@ void Savestate::Section(char* magic)
for (;;)
{
u32 buf;
u32 buf = 0;
fread(&buf, 4, 1, file);
if (buf != ((u32*)magic)[0])
@ -186,6 +190,7 @@ void Savestate::Section(char* magic)
return;
}
buf = 0;
fread(&buf, 4, 1, file);
fseek(file, buf-8, SEEK_CUR);
continue;