summaryrefslogtreecommitdiffstats
path: root/src/bluetooth/android
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2016-12-30 17:28:52 +0300
committerKonstantin Ritt <ritt.ks@gmail.com>2016-12-30 21:07:13 +0000
commit4cea8d733e1ece2ef0db6b5c64779530c03f798e (patch)
tree03405b8ce7b1b66feb21d65204e2dc9f7b745898 /src/bluetooth/android
parentb1e86c68d1154220a664efebf22e29eeb6a3fe99 (diff)
LE/Android: Fix crash due to references leak
in f945ffc90f8f11d73dc87f2d82bb2d246d446e71, a very basic scanRecord parser has been added, which calls GetByteArrayElements without releasing the elemnts, causing JNI core exception > E/dalvikvm: Failed adding to JNI pinned array ref table (1023 entries) Change-Id: I272593c232f0c87c1983f1f568aa6c3599d44253 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/bluetooth/android')
-rw-r--r--src/bluetooth/android/devicediscoverybroadcastreceiver.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp b/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
index c807df7f..9c9c0409 100644
--- a/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
+++ b/src/bluetooth/android/devicediscoverybroadcastreceiver.cpp
@@ -511,7 +511,8 @@ QBluetoothDeviceInfo DeviceDiscoveryBroadcastReceiver::retrieveDeviceInfo(JNIEnv
if (scanRecord != nullptr) {
// Parse scan record
jboolean isCopy;
- const char *scanRecordBuffer = reinterpret_cast<const char *>(env->GetByteArrayElements(scanRecord, &isCopy));
+ jbyte *elems = env->GetByteArrayElements(scanRecord, &isCopy);
+ const char *scanRecordBuffer = reinterpret_cast<const char *>(elems);
const int scanRecordLength = env->GetArrayLength(scanRecord);
QList<QBluetoothUuid> serviceUuids;
@@ -560,6 +561,8 @@ QBluetoothDeviceInfo DeviceDiscoveryBroadcastReceiver::retrieveDeviceInfo(JNIEnv
}
info.setServiceUuids(serviceUuids, QBluetoothDeviceInfo::DataIncomplete);
+
+ env->ReleaseByteArrayElements(scanRecord, elems, JNI_ABORT);
}
if (QtAndroidPrivate::androidSdkVersion() >= 18) {