summaryrefslogtreecommitdiffstats
path: root/jni/com_android_bluetooth_a2dp.cpp
diff options
context:
space:
mode:
authorScott Warner <Tortel1210@gmail.com>2016-11-15 05:53:42 -0500
committerScott Warner <Tortel1210@gmail.com>2016-11-15 11:17:01 -0500
commit168ecad49d4412d255c78dde937f4f960c58c779 (patch)
treebf432c81a1aa89538d0ccdd208b27da4746f6b57 /jni/com_android_bluetooth_a2dp.cpp
parent699645f59f1c9f2242c57dbaa3cedc36fa50002e (diff)
downloadandroid_packages_apps_Bluetooth-168ecad49d4412d255c78dde937f4f960c58c779.tar.gz
android_packages_apps_Bluetooth-168ecad49d4412d255c78dde937f4f960c58c779.tar.bz2
android_packages_apps_Bluetooth-168ecad49d4412d255c78dde937f4f960c58c779.zip
bluetooth: Prevent null pointer crashes in A2DP initNative
Change-Id: I91f555ae8f2311d80145fe6b33a6c93b1997ca66
Diffstat (limited to 'jni/com_android_bluetooth_a2dp.cpp')
-rw-r--r--jni/com_android_bluetooth_a2dp.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/jni/com_android_bluetooth_a2dp.cpp b/jni/com_android_bluetooth_a2dp.cpp
index 7c15c37db..fd286ffcc 100644
--- a/jni/com_android_bluetooth_a2dp.cpp
+++ b/jni/com_android_bluetooth_a2dp.cpp
@@ -221,7 +221,13 @@ static void initNative(JNIEnv *env, jobject object, jint maxA2dpConnections,
const char *offload_capabilities;
bt_status_t status;
- offload_capabilities = env->GetStringUTFChars(offload_cap, NULL);
+ // Calling GetStringUTFChars with a null jstring can cause ART to crash
+ if (offload_cap != NULL) {
+ offload_capabilities = env->GetStringUTFChars(offload_cap, NULL);
+ } else {
+ offload_capabilities = NULL;
+ }
+
if ( (btInf = getBluetoothInterface()) == NULL) {
ALOGE("Bluetooth module is not loaded");