commit | 0fd06a19bdc56fec8eb736d248abb56fe5a2727d | [log] [tgz] |
---|---|---|
author | Andre Eisenbach <eisenbach@google.com> | Tue Dec 09 16:42:14 2014 -0800 |
committer | Andre Eisenbach <eisenbach@google.com> | Tue Dec 09 16:42:14 2014 -0800 |
tree | 0881c663024bb2ba495cd880a86838c03bb29c61 | |
parent | c6de3212c2dd8638bf3150719ed331673fdcab06 [diff] [blame] |
Prevent NullPointerException in getStringValue if no value is set Bug: 18686365 Change-Id: I5f5d07ef49500e0d8118ba04aaf373ae4514f034
diff --git a/core/java/android/bluetooth/BluetoothGattCharacteristic.java b/core/java/android/bluetooth/BluetoothGattCharacteristic.java index a86677c..7cdcc2c 100644 --- a/core/java/android/bluetooth/BluetoothGattCharacteristic.java +++ b/core/java/android/bluetooth/BluetoothGattCharacteristic.java
@@ -502,7 +502,7 @@ * @return Cached value of the characteristic */ public String getStringValue(int offset) { - if (offset > mValue.length) return null; + if (mValue == null || offset > mValue.length) return null; byte[] strBytes = new byte[mValue.length - offset]; for (int i=0; i != (mValue.length-offset); ++i) strBytes[i] = mValue[offset+i]; return new String(strBytes);