1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-14 00:50:34 +02:00

Huami: Fix crash when calendar event desctription or title was null

Fixes #1813
This commit is contained in:
Andreas Shimokawa 2020-03-04 23:13:57 +01:00
parent a2d52438e2
commit 8cf7e259aa

View File

@ -1727,9 +1727,20 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
if (iteration > 8) { // limit ?
break;
}
calendar.setTimeInMillis(calendarEvent.getBegin());
byte[] title = calendarEvent.getTitle().getBytes();
byte[] body = calendarEvent.getDescription().getBytes();
byte[] title;
byte[] body;
if (calendarEvent.getTitle() != null) {
title = calendarEvent.getTitle().getBytes();
} else {
title = new byte[]{};
}
if (calendarEvent.getDescription() != null) {
body = calendarEvent.getDescription().getBytes();
} else {
body = new byte[]{};
}
int length = 18 + title.length + 1 + body.length + 1;
ByteBuffer buf = ByteBuffer.allocate(length);