mirror of
https://github.com/preble/libpinproc
synced 2026-02-22 18:15:25 +01:00
Fixed linked rules free list maintenance bug.
This commit is contained in:
@@ -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.
|
||||
PRSwitchRuleInternal *oldRule = GetSwitchRuleByIndex(newRuleIndex);
|
||||
|
||||
uint16_t oldLinkIndex;
|
||||
while (oldRule->linkActive)
|
||||
{
|
||||
// Save old link index so it can freed after the linked rule is retrieved.
|
||||
oldLinkIndex = 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.
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user