mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
properly initialize shit before attempting to read from the file
fixes load failure when attaching a debugger
This commit is contained in:
parent
b5c39680a5
commit
467461fb3d
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user