diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 32bf64002..9b535c12b 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -41,11 +41,15 @@ void RewindManager::setup() 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( + myOSystem.settings().getInt(prefix + "tm.size"), MAX_BUF_SIZE); if(mySize != myStateList.capacity()) resize(mySize); - myUncompressed = myOSystem.settings().getInt(prefix + "tm.uncompressed"); + myUncompressed = std::min( + myOSystem.settings().getInt(prefix + "tm.uncompressed"), MAX_BUF_SIZE); myInterval = INTERVAL_CYCLES[0]; for(int i = 0; i < NUM_INTERVALS; ++i) @@ -238,7 +242,7 @@ string RewindManager::saveAllStates() return "Can't save to all states file"; uInt32 curIdx = getCurrentIdx(); - rewindStates(1000); + rewindStates(MAX_BUF_SIZE); uInt32 numStates = uInt32(cyclesList().size()); // Save header diff --git a/src/common/RewindManager.hxx b/src/common/RewindManager.hxx index 447406642..328b6bb3d 100644 --- a/src/common/RewindManager.hxx +++ b/src/common/RewindManager.hxx @@ -49,6 +49,7 @@ class RewindManager RewindManager(OSystem& system, StateManager& statemgr); public: + static constexpr uInt32 MAX_BUF_SIZE = 1000; static constexpr int NUM_INTERVALS = 7; // cycle values for the intervals const uInt32 INTERVAL_CYCLES[NUM_INTERVALS] = {