summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-07-17 14:39:52 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2009-07-17 14:39:52 -0700
commit261a784c44d6ac4377651e4842c7a96326462857 (patch)
tree8f078ca69ecc7b04b567b4c4a9633c6d276b4f8b
parentcf492afdeb3a1da04cc71518285eb778f2ef6837 (diff)
parent4bac5a3928d57ac193141eb6d45f3b39200d27de (diff)
downloadframeworks_base-261a784c44d6ac4377651e4842c7a96326462857.zip
frameworks_base-261a784c44d6ac4377651e4842c7a96326462857.tar.gz
frameworks_base-261a784c44d6ac4377651e4842c7a96326462857.tar.bz2
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.
-rw-r--r--core/jni/android_media_AudioRecord.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp
index e71e348..44a9e8c 100644
--- a/core/jni/android_media_AudioRecord.cpp
+++ b/core/jni/android_media_AudioRecord.cpp
@@ -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;
}