From 5dbe3e696f672361de8d1b1b03a649bc9e51ff03 Mon Sep 17 00:00:00 2001 From: Adam Preble Date: Mon, 21 Sep 2009 23:12:41 -0400 Subject: [PATCH] libpinproc: fixed uninitialized memory that could cause memory consumption leading to a crash. pypinproc: changed linker path to point to ../bin. Added note about running in 64-bit environment (Snow Leopard). pyprocgame: debug printing enhancements jdtest: Fixed bug (not clearing out drop target mode). Added initial Splash.dmd. --- .gitignore | 1 + src/PRDevice.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 83e29ab..2fcf1c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +bin/ build/ */*.pbxuser */*.perspectivev3 diff --git a/src/PRDevice.cpp b/src/PRDevice.cpp index e01baa8..7f0e21d 100644 --- a/src/PRDevice.cpp +++ b/src/PRDevice.cpp @@ -86,10 +86,11 @@ PRResult PRDevice::Reset(uint32_t resetFlags) // Make sure the free list is empty. while (!freeSwitchRuleIndexes.empty()) freeSwitchRuleIndexes.pop(); + memset(switchRules, 0x00, sizeof(PRSwitchRuleInternal) * maxSwitchRules); + for (i = 0; i < kPRSwitchRulesCount; i++) { PRSwitchRuleInternal *switchRule = &switchRules[i]; - memset(switchRule, 0x00, sizeof(PRSwitchRule)); uint16_t ruleIndex = i; ParseSwitchRuleIndex(ruleIndex, &switchRule->switchNum, &switchRule->eventType); @@ -454,6 +455,12 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR { oldRule = GetSwitchRuleByIndex(oldRule->linkIndex); freeSwitchRuleIndexes.push(oldRule->linkIndex); + + if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory. + { + PRSetLastErrorText("Too many free switch rule indicies!"); + return kPRFailure; + } } // Now let's setup the first actual rule: