From b66bcfb3e2e3e484b66894492bb9200d9b8cd18e Mon Sep 17 00:00:00 2001 From: Dan Weiss Date: Thu, 31 Dec 2020 08:48:54 -0500 Subject: [PATCH] Fix SFMDATA getting a terminator that it shouldn't get if NULL pointer is given (#290) --- src/ines.cpp | 7 ++++++- src/state.cpp | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ines.cpp b/src/ines.cpp index 38ebe408..4c2d2e36 100644 --- a/src/ines.cpp +++ b/src/ines.cpp @@ -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; } diff --git a/src/state.cpp b/src/state.cpp index 778251d6..91f1f92e 100644 --- a/src/state.cpp +++ b/src/state.cpp @@ -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;