Skip to content

Commit ea8d506

Browse files
authored
fix: prevent segfault on Linux if device isn't opened (#2924)
1 parent 1bcfd8b commit ea8d506

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/communication/handler/desktop_comms_handler.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ class DesktopUSBCommunicationHandler implements CommunicationHandler {
6161
throw Exception("Device not connected");
6262
}
6363
UsbSerialDevice.setAutoDetachKernelDriver(true);
64-
await mDevice?.open();
64+
if (await mDevice?.open() == false) {
65+
logger.e("Failed to open device");
66+
return;
67+
}
6568
await mDevice?.setBaudRate(1000000);
6669
await mDevice?.setDataBits(UsbSerialInterface.dataBits8);
6770
await mDevice?.setStopBits(UsbSerialInterface.stopBits1);

0 commit comments

Comments
 (0)