mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1232670: Prepare Bluetooth PDU for sending after checking connection status, r=shuang
The PDU contains a pointer to the operation's result handler. If sending fails, the result handler is supposed to handle an error. But the PDU will go out of scope first and release the handler. The error delivery then fails with a segmentation fault.
This commit is contained in:
parent
c7cfbb88ac
commit
989aaf55fc
@ -145,15 +145,15 @@ BluetoothDaemonProtocol::Send(DaemonSocketPDU* aPDU,
|
||||
MOZ_ASSERT(mConnection);
|
||||
MOZ_ASSERT(aPDU);
|
||||
|
||||
aPDU->SetConsumer(this);
|
||||
aPDU->SetResultHandler(aRes);
|
||||
aPDU->UpdateHeader();
|
||||
|
||||
if (mConnection->GetConnectionStatus() == SOCKET_DISCONNECTED) {
|
||||
BT_LOGR("Connection to Bluetooth daemon is closed.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
aPDU->SetConsumer(this);
|
||||
aPDU->SetResultHandler(aRes);
|
||||
aPDU->UpdateHeader();
|
||||
|
||||
mConnection->SendSocketData(aPDU); // Forward PDU to command channel
|
||||
|
||||
return NS_OK;
|
||||
|
Loading…
Reference in New Issue
Block a user