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