Merge change 7720 into donut

* changes:
  Fix global ref leak in android.media.AudioRecord. Delete global refs to the native AudioRecord pointer and the callback cookie (for native to Java calls) in the finalize() function and when an error occurs during the allocation of the native resources.
This commit is contained in:
Android (Google) Code Review
2009-07-17 14:39:52 -07:00

View File

@ -212,8 +212,10 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
// failure:
native_init_failure:
env->DeleteGlobalRef(lpCallbackData->audioRecord_class);
env->DeleteGlobalRef(lpCallbackData->audioRecord_ref);
delete lpCallbackData;
native_track_failure:
delete lpRecorder;
@ -274,6 +276,8 @@ static void android_media_AudioRecord_finalize(JNIEnv *env, jobject thiz) {
thiz, javaAudioRecordFields.nativeCallbackCookie);
if (lpCookie) {
LOGV("deleting lpCookie: %x\n", (int)lpCookie);
env->DeleteGlobalRef(lpCookie->audioRecord_class);
env->DeleteGlobalRef(lpCookie->audioRecord_ref);
delete lpCookie;
}