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

Commit b7e10920 authored by George Burgess IV's avatar George Burgess IV
Browse files

gatt: fix potential use of NULL

It seems that `jniThrowIOException` doesn't unwind the stack -- it just
stores some info so that when the _caller_ returns control to the JVM,
the JVM can handle unwinding of Java frames. Hence, we should be
returning after these.

Caught by the static analyzer:
> packages/apps/Bluetooth/jni/com_android_bluetooth_gatt.cpp:1536:23:
warning: Array access (from variable 'irkBytes') results in a null
pointer dereference [clang-analyzer-core.NullDereference]

Bug: 194432570
Test: TreeHugger
Tag: #feature
Change-Id: I11a690b10de825dfb855685d68aafac5b6273ca4
parent c4e9aa36
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1527,10 +1527,12 @@ static void gattClientScanFilterAddNative(JNIEnv* env, jobject object,
      if (len != 16) {
        ALOGE("%s: Invalid IRK length '%d'; expected 16", __func__, len);
        jniThrowIOException(env, EINVAL);
        return;
      }
      jbyte* irkBytes = env->GetByteArrayElements(irkByteArray.get(), NULL);
      if (irkBytes == NULL) {
        jniThrowIOException(env, EINVAL);
        return;
      }
      for (int j = 0; j < len; j++) {
        curr.irk[j] = irkBytes[j];