Skip to content

Conversation

@doudar
Copy link
Contributor

@doudar doudar commented Feb 12, 2026

This pull request makes several improvements and bug fixes to the whitelist management logic in NimBLEDevice. The changes focus on safer and more efficient handling of the internal whitelist vector, as well as correcting a boundary check bug.

Whitelist management improvements:

  • Changed usage of m_whiteList from pointer arithmetic (&m_whiteList[0]) to the safer and more idiomatic m_whiteList.data() when passing data to ble_gap_wl_set.
  • In whiteListRemove, now passes nullptr to ble_gap_wl_set when the whitelist is empty, preventing invalid pointer dereference. Also uses m_whiteList.shrink_to_fit() to optimize memory usage after removal, replacing the previous swap idiom.

Bug fix:

  • Corrected the boundary check in getWhiteListAddress from index > m_whiteList.size() to index >= m_whiteList.size(), fixing an off-by-one error when accessing whitelist entries.

Copilot AI and others added 7 commits February 12, 2026 06:07
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
Compact whitelist handling in NimBLEDevice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants