mirror of https://github.com/stella-emu/stella.git
Fix missing bounds checking, reported by Coverity.
This area of the code could also use some named constants, which are also used in DeveloperDialog.
This commit is contained in:
parent
f3e2c401c0
commit
8bf39568ab
|
@ -41,11 +41,15 @@ void RewindManager::setup()
|
||||||
|
|
||||||
const string& prefix = myOSystem.settings().getBool("dev.settings") ? "dev." : "plr.";
|
const string& prefix = myOSystem.settings().getBool("dev.settings") ? "dev." : "plr.";
|
||||||
|
|
||||||
mySize = myOSystem.settings().getInt(prefix + "tm.size");
|
// TODO - Add proper bounds checking (define constexpr variables for this)
|
||||||
|
// Use those bounds in DeveloperDialog too
|
||||||
|
mySize = std::min<uInt32>(
|
||||||
|
myOSystem.settings().getInt(prefix + "tm.size"), MAX_BUF_SIZE);
|
||||||
if(mySize != myStateList.capacity())
|
if(mySize != myStateList.capacity())
|
||||||
resize(mySize);
|
resize(mySize);
|
||||||
|
|
||||||
myUncompressed = myOSystem.settings().getInt(prefix + "tm.uncompressed");
|
myUncompressed = std::min<uInt32>(
|
||||||
|
myOSystem.settings().getInt(prefix + "tm.uncompressed"), MAX_BUF_SIZE);
|
||||||
|
|
||||||
myInterval = INTERVAL_CYCLES[0];
|
myInterval = INTERVAL_CYCLES[0];
|
||||||
for(int i = 0; i < NUM_INTERVALS; ++i)
|
for(int i = 0; i < NUM_INTERVALS; ++i)
|
||||||
|
@ -238,7 +242,7 @@ string RewindManager::saveAllStates()
|
||||||
return "Can't save to all states file";
|
return "Can't save to all states file";
|
||||||
|
|
||||||
uInt32 curIdx = getCurrentIdx();
|
uInt32 curIdx = getCurrentIdx();
|
||||||
rewindStates(1000);
|
rewindStates(MAX_BUF_SIZE);
|
||||||
uInt32 numStates = uInt32(cyclesList().size());
|
uInt32 numStates = uInt32(cyclesList().size());
|
||||||
|
|
||||||
// Save header
|
// Save header
|
||||||
|
|
|
@ -49,6 +49,7 @@ class RewindManager
|
||||||
RewindManager(OSystem& system, StateManager& statemgr);
|
RewindManager(OSystem& system, StateManager& statemgr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static constexpr uInt32 MAX_BUF_SIZE = 1000;
|
||||||
static constexpr int NUM_INTERVALS = 7;
|
static constexpr int NUM_INTERVALS = 7;
|
||||||
// cycle values for the intervals
|
// cycle values for the intervals
|
||||||
const uInt32 INTERVAL_CYCLES[NUM_INTERVALS] = {
|
const uInt32 INTERVAL_CYCLES[NUM_INTERVALS] = {
|
||||||
|
|
Loading…
Reference in New Issue