diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5649bfd7a..2eebd64ed 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -879,10 +879,11 @@ meshtastic_NodeInfoLite *NodeDB::getOrCreateMeshNode(NodeNum n) if ((*numMeshNodes >= MAX_NUM_NODES) || (memGet.getFreeHeap() < meshtastic_NodeInfoLite_size * 3)) { if (screen) screen->print("warning: node_db_lite full! erasing oldest entry\n"); + LOG_INFO("warning: node_db_lite full! erasing oldest entry\n"); // look for oldest node and erase it uint32_t oldest = UINT32_MAX; int oldestIndex = -1; - for (int i = 0; i < *numMeshNodes; i++) { + for (int i = 1; i < *numMeshNodes; i++) { if (meshNodes[i].last_heard < oldest) { oldest = meshNodes[i].last_heard; oldestIndex = i; @@ -926,4 +927,4 @@ void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, co LOG_ERROR("A critical failure occurred, portduino is exiting..."); exit(2); #endif -} +} \ No newline at end of file diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 1113bc976..5e808b6b6 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -204,6 +204,8 @@ int32_t PositionModule::runOnce() } meshtastic_NodeInfoLite *node = nodeDB.getMeshNode(nodeDB.getNodeNum()); + if (node == nullptr) + return RUNONCE_INTERVAL; // We limit our GPS broadcasts to a max rate uint32_t now = millis();