system/bt
Revision | d92387bc0ad8eb08374e1ad4d30f243d75774dc1 (tree) |
---|---|
Time | 2019-11-08 09:19:43 |
Author | Nick Desaulniers <ndesaulniers@goog...> |
Commiter | Kyriakos Ispoglou |
[system][bt] fix -Wdangling-gsl
BtAddrString() returns a std::string. It's not safe to chain a call to
c_str() as otherwise the returned std::string is a temporary, and the
expression evaluates to an immediately dangling pointer.
Bug: 139945549
Bug: 142558228
Test: mm
Change-Id: I30972458abcc563b24ee0d80b289c3efd6c3e04d
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
(cherry picked from commit 20ed45d6339079645ef9fe576b894e9497684c93)
@@ -188,8 +188,8 @@ void LowEnergyClient::MtuChangedCallback( | ||
188 | 188 | |
189 | 189 | if (!bda) return; |
190 | 190 | |
191 | - const char* addr = BtAddrString(bda).c_str(); | |
192 | - if (delegate_) delegate_->OnMtuChanged(this, status, addr, mtu); | |
191 | + std::string addr = BtAddrString(bda); | |
192 | + if (delegate_) delegate_->OnMtuChanged(this, status, addr.c_str(), mtu); | |
193 | 193 | } |
194 | 194 | |
195 | 195 | // LowEnergyClientFactory implementation |