1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-24 18:25:23 +01:00

Fixed linked rules free list maintenance bug.

This commit is contained in:
gstellenberg
2010-02-23 13:20:21 -06:00
parent 3155dc9a10
commit 00009be170

View File

@@ -544,10 +544,14 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
// Because we're redefining the rule chain, we need to remove all previously existing links and return the indexes to the free list. // Because we're redefining the rule chain, we need to remove all previously existing links and return the indexes to the free list.
PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex); PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex);
uint16_t oldLinkIndex;
while (oldRule->linkActive) while (oldRule->linkActive)
{ {
// Save old link index so it can freed after the linked rule is retrieved.
oldLinkIndex = oldRule->linkIndex;
oldRule = GetSwitchRuleByIndex(oldRule->linkIndex); oldRule = GetSwitchRuleByIndex(oldRule->linkIndex);
freeSwitchRuleIndexes.push(oldRule->linkIndex); freeSwitchRuleIndexes.push(oldLinkIndex);
if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory. if (freeSwitchRuleIndexes.size() > 128) // Detect a corrupted link-related values before it eats up all of the memory.
{ {