diff options
author | Christian Wassmuth <c.wassmuth@oculus.de> | 2017-01-10 09:55:50 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2017-01-12 15:45:46 +0000 |
commit | 60f2f09fa5c402cff7a84f0c56cfa6880968b814 (patch) | |
tree | 57f0619e655b5a8b40fabba398756087075dc4c1 /src/android | |
parent | 1b86d493e016efbe6b4de99d7fdffabb9b31f25b (diff) |
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 <alexander.blasche@qt.io>
Diffstat (limited to 'src/android')
-rw-r--r-- | src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java | 3 |
1 files changed, 2 insertions, 1 deletions
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."); |