From 0c80f4f100f395bf7ed61c217ee6f6822de8d7c8 Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Sat, 27 Dec 2025 23:47:17 -0500 Subject: [PATCH] fix(ble): Clean up address_to_identity in _cleanup_stale_interface() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The _cleanup_stale_interface() method was cleaning up identity_to_address but not the reverse mapping address_to_identity. This caused: - Memory leak: stale entries accumulate over time - Inconsistent state: bidirectional mappings become out of sync This fix matches the cleanup pattern in _disconnected_callback() which properly cleans up both directions of the mapping. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/RNS/Interfaces/BLEInterface.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/RNS/Interfaces/BLEInterface.py b/src/RNS/Interfaces/BLEInterface.py index 22ac5ba..44f9bb8 100644 --- a/src/RNS/Interfaces/BLEInterface.py +++ b/src/RNS/Interfaces/BLEInterface.py @@ -1036,9 +1036,11 @@ class BLEInterface(Interface): old_interface.detach() RNS.log(f"{self} detached stale interface for {identity_hash[:8]}", RNS.LOG_DEBUG) - # Clean up address mappings + # Clean up address mappings (both directions) if identity_hash in self.identity_to_address: del self.identity_to_address[identity_hash] + if old_address in self.address_to_identity: + del self.address_to_identity[old_address] # Clean up fragmenter/reassembler for old address if peer_identity: