Skip to content

Commit

Permalink
fix nodeDB erase loop when free mem returns invalid value (0, -1). (#…
Browse files Browse the repository at this point in the history
…5519)

Co-authored-by: mverch67 <[email protected]>
  • Loading branch information
fifieldt and mverch67 authored Dec 7, 2024
1 parent de77418 commit bac9fec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/mesh/NodeDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,11 +1372,14 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
if (oldestBoringIndex != -1) {
oldestIndex = oldestBoringIndex;
}
// Shove the remaining nodes down the chain
for (int i = oldestIndex; i < numMeshNodes - 1; i++) {
meshNodes->at(i) = meshNodes->at(i + 1);

if (oldestIndex != -1) {
// Shove the remaining nodes down the chain
for (int i = oldestIndex; i < numMeshNodes - 1; i++) {
meshNodes->at(i) = meshNodes->at(i + 1);
}
(numMeshNodes)--;
}
(numMeshNodes)--;
}
// add the node at the end
lite = &meshNodes->at((numMeshNodes)++);
Expand Down

0 comments on commit bac9fec

Please sign in to comment.