Skip to content

Commit 3e7a286

Browse files
committed
pbio/drv/bluetooth: Fix peripheral disconnect if config unset.
The pbdrv_bluetooth_is_connected check should protect against this, but if it fails we get a segfault if config was never set, so if no peripheral was ever connected.
1 parent 2e656ff commit 3e7a286

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

lib/pbio/drv/bluetooth/bluetooth.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,12 @@ pbio_error_t pbdrv_bluetooth_peripheral_disconnect(void) {
188188
return PBIO_SUCCESS;
189189
}
190190

191+
// Clear notification handler to avoid receiving further data.
192+
if (peri->config) {
193+
peri->config->notification_handler = NULL;
194+
}
195+
191196
// Initialize operation for handling on the main thread.
192-
peri->config->notification_handler = NULL;
193197
peri->func = pbdrv_bluetooth_peripheral_disconnect_func;
194198
peri->err = PBIO_ERROR_AGAIN;
195199
pbio_os_request_poll();

0 commit comments

Comments
 (0)