Skip to content

Commit

Permalink
Fix array out of bounds crash
Browse files Browse the repository at this point in the history
  • Loading branch information
weliem committed Apr 15, 2022
1 parent 51fe74e commit 9c3bcff
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ class BluetoothBytesParser (
* @return flase if the calendar object was null, otherwise true
*/
fun setCurrentTime(calendar: Calendar): Boolean {
value = ByteArray(10)
prepareArray(10)
setDateTime(calendar)
value[7] = ((calendar[Calendar.DAY_OF_WEEK] + 5) % 7 + 1).toByte()
value[8] = (calendar[Calendar.MILLISECOND] * 256 / 1000).toByte()
Expand All @@ -569,7 +569,7 @@ class BluetoothBytesParser (
* @return flase if the calendar object was null, otherwise true
*/
fun setDateTime(calendar: Calendar): Boolean {
value = ByteArray(7)
prepareArray(7)
value[0] = calendar[Calendar.YEAR].toByte()
value[1] = (calendar[Calendar.YEAR] shr 8).toByte()
value[2] = (calendar[Calendar.MONTH] + 1).toByte()
Expand Down

0 comments on commit 9c3bcff

Please sign in to comment.