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
  • Loading branch information
mverch67 authored and fifieldt committed Dec 7, 2024
1 parent de77418 commit f9bbd8a
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 f9bbd8a

Please sign in to comment.