diff --git a/app/lib/services/devices/plaud_connection.dart b/app/lib/services/devices/plaud_connection.dart index ea2ee25efa..92a33ffeaa 100644 --- a/app/lib/services/devices/plaud_connection.dart +++ b/app/lib/services/devices/plaud_connection.dart @@ -72,6 +72,7 @@ class PlaudDeviceConnection extends DeviceConnection { if (position == 0xFFFFFFFF) return null; // End marker final length = payload[8]; + if (9 + length > payload.length) return null; return payload.sublist(9, 9 + length); } @@ -287,7 +288,8 @@ class PlaudDeviceConnection extends DeviceConnection { @override Future performGetImageListener({ required void Function(OrientedImage orientedImage) onImageReceived, - }) async => null; + }) async => + null; @override Future>?> performGetAccelListener({void Function(int)? onAccelChange}) async => null; @@ -319,15 +321,15 @@ class PlaudDeviceConnection extends DeviceConnection { List _toBytes32(int v) => [v & 0xFF, (v >> 8) & 0xFF, (v >> 16) & 0xFF, (v >> 24) & 0xFF]; List _toBytes64(int v) => [ - v & 0xFF, - (v >> 8) & 0xFF, - (v >> 16) & 0xFF, - (v >> 24) & 0xFF, - (v >> 32) & 0xFF, - (v >> 40) & 0xFF, - (v >> 48) & 0xFF, - (v >> 56) & 0xFF, - ]; + v & 0xFF, + (v >> 8) & 0xFF, + (v >> 16) & 0xFF, + (v >> 24) & 0xFF, + (v >> 32) & 0xFF, + (v >> 40) & 0xFF, + (v >> 48) & 0xFF, + (v >> 56) & 0xFF, + ]; int _toInt32(List b) => b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); }