mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-27 02:14:37 +00:00
fix nodeDB erase loop when free mem returns invalid value (0, -1). (#5519)
Co-authored-by: mverch67 <manuel.verch@gmx.de>
This commit is contained in:
parent
de774188c9
commit
bac9fec17f
@ -1372,12 +1372,15 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n)
|
|||||||
if (oldestBoringIndex != -1) {
|
if (oldestBoringIndex != -1) {
|
||||||
oldestIndex = oldestBoringIndex;
|
oldestIndex = oldestBoringIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (oldestIndex != -1) {
|
||||||
// Shove the remaining nodes down the chain
|
// Shove the remaining nodes down the chain
|
||||||
for (int i = oldestIndex; i < numMeshNodes - 1; i++) {
|
for (int i = oldestIndex; i < numMeshNodes - 1; i++) {
|
||||||
meshNodes->at(i) = meshNodes->at(i + 1);
|
meshNodes->at(i) = meshNodes->at(i + 1);
|
||||||
}
|
}
|
||||||
(numMeshNodes)--;
|
(numMeshNodes)--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// add the node at the end
|
// add the node at the end
|
||||||
lite = &meshNodes->at((numMeshNodes)++);
|
lite = &meshNodes->at((numMeshNodes)++);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user