mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 22:56:12 -04:00
Fix bluetooth socket crash during release of resource
From the crash call stack, the app crashed at the line `windows_socket = nullptr;` This is because the previous line `windows_socket_.Close();` has already released all unmanaged resources associated with the StreamSocket object. https://learn.microsoft.com/en-us/uwp/api/windows.networking.sockets.streamsocket.close?view=winrt-22621#remarks By RAII, assigning `windows_socket_` to nullptr is equivalent to calling `delete` on the StreamSocket allocated on the heap again, which results in null pointer exception `Exception infoEXCEPTION_ACCESS_VIOLATION_READ @0x00000000` because it has already been released in the previous line by Close(). PiperOrigin-RevId: 508454142
This commit is contained in:
committed by
Copybara-Service
parent
be32b7d2d9
commit
b8627563a0
@@ -89,7 +89,6 @@ Exception BluetoothSocket::Close() {
|
||||
try {
|
||||
if (windows_socket_ != nullptr) {
|
||||
windows_socket_.Close();
|
||||
windows_socket_ = nullptr;
|
||||
}
|
||||
return {Exception::kSuccess};
|
||||
} catch (std::exception exception) {
|
||||
|
||||
Reference in New Issue
Block a user