From 60f2f09fa5c402cff7a84f0c56cfa6880968b814 Mon Sep 17 00:00:00 2001 From: Christian Wassmuth Date: Tue, 10 Jan 2017 09:55:50 +0100 Subject: Prevents a nil exception, if a descriptor read fails during discovery During discovery, if a descriptor read fails the current implementation tries to read from a nil bytearray. Now the bytearray is checked before access. Change-Id: Ic04809fa81c25c7abdd8a82a1ccefe43de7f5605 Reviewed-by: Alex Blasche --- .../src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/android') diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java index c06531ea..4d9e0d46 100644 --- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java +++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java @@ -394,7 +394,8 @@ public class QtBluetoothLE { * up here. */ if (descriptor.getUuid().compareTo(clientCharacteristicUuid) == 0) { - final int value = descriptor.getValue()[0]; + byte[] bytearray = descriptor.getValue(); + final int value = (bytearray != null && bytearray.length > 0) ? bytearray[0] : 0; // notification or indication bit set? if ((value & 0x03) > 0) { Log.d(TAG, "Found descriptor with automatic notifications."); -- cgit v1.2.3