Fix SFMDATA getting a terminator that it shouldn't get if NULL pointer is given (#290)

This commit is contained in:
Dan Weiss 2020-12-31 08:48:54 -05:00 committed by GitHub
parent 61709a0e6d
commit b66bcfb3e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -1057,7 +1057,12 @@ static int iNES_Init(int num) {
}
}
if (head.ROM_type & 8)
AddExState(ExtraNTARAM, 2048, 0, "EXNR");
{
if (ExtraNTARAM != NULL)
{
AddExState(ExtraNTARAM, 2048, 0, "EXNR");
}
}
tmp->init(&iNESCart);
return 0;
}

View File

@ -860,6 +860,9 @@ void ResetExState(void (*PreSave)(void), void (*PostSave)(void))
void AddExState(void *v, uint32 s, int type, const char *desc)
{
//do not accept extra state information if a null pointer was provided for v, so list won't terminate early
if (v == 0) return;
if(s==~0)
{
SFORMAT* sf = (SFORMAT*)v;