Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 93763e78 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Get rid of memory leak in remote name request handling

The memory that's osi_malloc here is never freed.
Pointer p is passed either to btm_process_remote_name, or to
btm_sec_rmt_name_request_complete. Inside 2nd method, it's passed to
btm_process_remote_name. In all those places, the content of array is
copied, but the pointer is never released.

Bug: None
Flag: exempt, trivial fix
Test: manual, observe device names are ok during scanning.
Change-Id: I75279b5e0c2901161b51181a3eca120a556e1491
parent b4fe8291
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
@@ -227,13 +227,10 @@ void bluetooth::shim::ACL_RemoteNameRequest(const RawAddress& addr,
                base::BindOnce(
                    [](RawAddress addr, hci::ErrorCode status,
                       std::array<uint8_t, 248> name) {
                      auto p = (uint8_t*)osi_malloc(name.size());
                      std::copy(name.begin(), name.end(), p);

                      btm_process_remote_name(&addr, p, name.size(),
                      btm_process_remote_name(&addr, name.data(), name.size(),
                                              static_cast<tHCI_STATUS>(status));
                      btm_sec_rmt_name_request_complete(
                          &addr, p, static_cast<tHCI_STATUS>(status));
                          &addr, name.data(), static_cast<tHCI_STATUS>(status));
                    },
                    addr, status, name));
          },