AudioRecord JNI: fix mem leak on audio_attributes_t
Free memory calloc'd to hold audio_attributes_t for the AudioRecord instance. Bug: 109700675 Test: see bug Change-Id: I688c6d2ee4a2db5a4d96b54e33bcc7237daef235
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user