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

Commit 2e73ff5e authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Merge "AudioRecord JNI: fix mem leak on audio_attributes_t" into pi-dev

parents b4e4fc3a 4ce27b51
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -368,10 +368,19 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
    // of the Java object (in mNativeCallbackCookie) so we can free the memory in finalize()
    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, (jlong)lpCallbackData);

    if (paa != NULL) {
        // audio attributes were copied in AudioRecord creation
        free(paa);
        paa = NULL;
    }

    return (jint) AUDIO_JAVA_SUCCESS;

    // failure:
native_init_failure:
    if (paa != NULL) {
        free(paa);
    }
    env->DeleteGlobalRef(lpCallbackData->audioRecord_class);
    env->DeleteGlobalRef(lpCallbackData->audioRecord_ref);
    delete lpCallbackData;