mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-14 22:47:18 +00:00
Fix memory leak in NextHopRouter: always free packet copy when removing from pending
This commit is contained in:
parent
35340fc6e2
commit
0fc33c352a
@ -182,12 +182,18 @@ bool NextHopRouter::stopRetransmission(GlobalPacketId key)
|
|||||||
if (isFromUs(p) || roleAllowsCancelingFromTxQueue(p)) {
|
if (isFromUs(p) || roleAllowsCancelingFromTxQueue(p)) {
|
||||||
// remove the 'original' (identified by originator and packet->id) from the txqueue and free it
|
// remove the 'original' (identified by originator and packet->id) from the txqueue and free it
|
||||||
cancelSending(getFrom(p), p->id);
|
cancelSending(getFrom(p), p->id);
|
||||||
// now free the pooled copy for retransmission too
|
|
||||||
packetPool.release(p);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Regardless of whether or not we canceled this packet from the txQueue, remove it from our pending list so it doesn't
|
||||||
|
// get scheduled again. (This is the core of stopRetransmission.)
|
||||||
auto numErased = pending.erase(key);
|
auto numErased = pending.erase(key);
|
||||||
assert(numErased == 1);
|
assert(numErased == 1);
|
||||||
|
|
||||||
|
// When we remove an entry from pending, always be sure to release the copy of the packet that was allocated in the call
|
||||||
|
// to startRetransmission.
|
||||||
|
packetPool.release(p);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user