MDT: prevent ArrayIndexOutOfBoundsException

This commit is contained in:
Milos Kozak 2021-10-26 14:03:54 +02:00
parent c1290ce766
commit c3a52c5969

View file

@ -94,6 +94,10 @@ class MedtronicConverter @Inject constructor(
}
fun decodeTime(rawContent: ByteArray): LocalDateTime? {
if (rawContent.size < 7) {
aapsLogger.error(LTag.PUMPCOMM, "decodeTime: Byte array too short")
return null
}
val hours = ByteUtil.asUINT8(rawContent[0])
val minutes = ByteUtil.asUINT8(rawContent[1])
val seconds = ByteUtil.asUINT8(rawContent[2])