diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index 65633bdfd..1da057626 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -993,6 +993,10 @@ bool BaseChatMesh::removeContact(ContactInfo& contact) { removeSessionKey(contact.id.pub_key); // also remove session key if any + // adjust pending rekey index before shifting array + if (_pending_rekey_idx == idx) _pending_rekey_idx = -1; + else if (_pending_rekey_idx > idx) _pending_rekey_idx--; + // remove from contacts array and parallel nonce tracking num_contacts--; while (idx < num_contacts) {