Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 385c20ea authored by xutianguo's avatar xutianguo Committed by Myles Watson
Browse files

Set sJniAdapterServiceObj to NULL after deleting it.



The global reference of sJniAdapterServiceObj(also other Objs)
object was deleted,  but we does not set it to NULL. As a result,
crash happened later when we access this object again.

Test: Enabled multi users and turn on/off bluetooth in multi
user spaces over 1000 times, everything is okay.

Bug: 38485697

Change-Id: Idb61b21b97bbe56c02bcf255c195cc33d5514ed1
Signed-off-by: default avatarxutianguo <xutianguo@xiaomi.com>
parent 41d92268
Loading
Loading
Loading
Loading
+15 −4
Original line number Original line Diff line number Diff line
@@ -691,10 +691,21 @@ static bool cleanupNative(JNIEnv* env, jobject obj) {
  sBluetoothInterface->cleanup();
  sBluetoothInterface->cleanup();
  ALOGI("%s: return from cleanup", __func__);
  ALOGI("%s: return from cleanup", __func__);


  if (sJniCallbacksObj) {
    env->DeleteGlobalRef(sJniCallbacksObj);
    env->DeleteGlobalRef(sJniCallbacksObj);
    sJniCallbacksObj = NULL;
  }

  if (sJniAdapterServiceObj) {
    env->DeleteGlobalRef(sJniAdapterServiceObj);
    env->DeleteGlobalRef(sJniAdapterServiceObj);
    sJniAdapterServiceObj = NULL;
  }

  if (android_bluetooth_UidTraffic.clazz) {
    env->DeleteGlobalRef(android_bluetooth_UidTraffic.clazz);
    env->DeleteGlobalRef(android_bluetooth_UidTraffic.clazz);
    android_bluetooth_UidTraffic.clazz = NULL;
    android_bluetooth_UidTraffic.clazz = NULL;
  }

  return JNI_TRUE;
  return JNI_TRUE;
}
}