mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-14 14:31:24 +00:00
Fix memory leak in NimbleBluetooth: allocate BluetoothStatus on stack, not heap
This commit is contained in:
parent
106a052950
commit
43cf12edfb
@ -133,7 +133,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
LOG_INFO("*** Enter passkey %d on the peer side ***", passkey);
|
LOG_INFO("*** Enter passkey %d on the peer side ***", passkey);
|
||||||
|
|
||||||
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
|
powerFSM.trigger(EVENT_BLUETOOTH_PAIR);
|
||||||
bluetoothStatus->updateStatus(new meshtastic::BluetoothStatus(std::to_string(passkey)));
|
meshtastic::BluetoothStatus newStatus(std::to_string(passkey));
|
||||||
|
bluetoothStatus->updateStatus(&newStatus);
|
||||||
|
|
||||||
#if HAS_SCREEN // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
#if HAS_SCREEN // Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
||||||
if (screen) {
|
if (screen) {
|
||||||
@ -173,7 +174,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
{
|
{
|
||||||
LOG_INFO("BLE authentication complete");
|
LOG_INFO("BLE authentication complete");
|
||||||
|
|
||||||
bluetoothStatus->updateStatus(new meshtastic::BluetoothStatus(meshtastic::BluetoothStatus::ConnectionState::CONNECTED));
|
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::CONNECTED);
|
||||||
|
bluetoothStatus->updateStatus(&newStatus);
|
||||||
|
|
||||||
// Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
// Todo: migrate this display code back into Screen class, and observe bluetoothStatus
|
||||||
if (passkeyShowing) {
|
if (passkeyShowing) {
|
||||||
@ -187,8 +189,8 @@ class NimbleBluetoothServerCallback : public NimBLEServerCallbacks
|
|||||||
{
|
{
|
||||||
LOG_INFO("BLE disconnect");
|
LOG_INFO("BLE disconnect");
|
||||||
|
|
||||||
bluetoothStatus->updateStatus(
|
meshtastic::BluetoothStatus newStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED);
|
||||||
new meshtastic::BluetoothStatus(meshtastic::BluetoothStatus::ConnectionState::DISCONNECTED));
|
bluetoothStatus->updateStatus(&newStatus);
|
||||||
|
|
||||||
if (bluetoothPhoneAPI) {
|
if (bluetoothPhoneAPI) {
|
||||||
std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->nimble_mutex);
|
std::lock_guard<std::mutex> guard(bluetoothPhoneAPI->nimble_mutex);
|
||||||
|
Loading…
Reference in New Issue
Block a user