summaryrefslogtreecommitdiffstats
path: root/components/proximity_auth
diff options
context:
space:
mode:
authorsacomoto <sacomoto@chromium.org>2015-07-07 04:25:07 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-07 11:25:42 +0000
commitf2b3c7a731b9bc0c8afdb0b877f4ee2bfba36243 (patch)
tree7e8a83567ad7c29cc50298c068624649d986d6e1 /components/proximity_auth
parent178208c0b13b0e65f23bdfce7310229bba4c46fb (diff)
downloadchromium_src-f2b3c7a731b9bc0c8afdb0b877f4ee2bfba36243.zip
chromium_src-f2b3c7a731b9bc0c8afdb0b877f4ee2bfba36243.tar.gz
chromium_src-f2b3c7a731b9bc0c8afdb0b877f4ee2bfba36243.tar.bz2
Fixing a crash in ProximityAuthBleSystem.
This CL fixes a bug causing crashes in proximity_auth::ProximityAuthBleSystem: - BluetoothLowEnergyConnection::Disconnect() should only change its status to DISCONNECTED after performing all operations. Otherwise, it will trigger a notification to its observers, which may then destroy the instance, causing a crash when |BluetoothLowEnergyConnection::Disconnect()| resume executing. BUG=506196 Review URL: https://codereview.chromium.org/1222563002 Cr-Commit-Position: refs/heads/master@{#337586}
Diffstat (limited to 'components/proximity_auth')
-rw-r--r--components/proximity_auth/ble/bluetooth_low_energy_connection.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection.cc
index 550cbf2..a6d732a 100644
--- a/components/proximity_auth/ble/bluetooth_low_energy_connection.cc
+++ b/components/proximity_auth/ble/bluetooth_low_energy_connection.cc
@@ -96,7 +96,6 @@ void BluetoothLowEnergyConnection::Disconnect() {
if (sub_status_ != SubStatus::DISCONNECTED) {
ClearWriteRequestsQueue();
StopNotifySession();
- SetSubStatus(SubStatus::DISCONNECTED);
if (gatt_connection_) {
PA_LOG(INFO) << "Disconnect from device "
<< gatt_connection_->GetDeviceAddress();
@@ -104,6 +103,10 @@ void BluetoothLowEnergyConnection::Disconnect() {
// Destroying BluetoothGattConnection also disconnects it.
gatt_connection_.reset();
}
+ // Only transition to the DISCONNECTED state after perfoming all necessary
+ // operations. Otherwise, it'll trigger observers that can pontentially
+ // destroy the current instance (causing a crash).
+ SetSubStatus(SubStatus::DISCONNECTED);
}
}