From 67a12184776605b6e6ddc01ca91b533a2e37a40b Mon Sep 17 00:00:00 2001 From: "Mike J. Chen" Date: Fri, 26 Apr 2013 12:34:52 -0700 Subject: Fix a crash case There's a runtime check for a bad argument, but it is after the usage of the bad argument. Move the usage after the check. Bug 8687716 Change-Id: Iddfa457951bac69b436a430cda21b5d7a563107b Signed-off-by: Mike J. Chen --- media/jni/audioeffect/android_media_Visualizer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'media/jni') diff --git a/media/jni/audioeffect/android_media_Visualizer.cpp b/media/jni/audioeffect/android_media_Visualizer.cpp index c2655c7..4d77cfd 100644 --- a/media/jni/audioeffect/android_media_Visualizer.cpp +++ b/media/jni/audioeffect/android_media_Visualizer.cpp @@ -164,17 +164,18 @@ static void captureCallback(void* user, visualizer_callback_cookie *callbackInfo = (visualizer_callback_cookie *)user; JNIEnv *env = AndroidRuntime::getJNIEnv(); - AutoMutex lock(&callbackInfo->callback_data_lock); + + if (!user || !env) { + ALOGW("captureCallback error user %p, env %p", user, env); + return; + } ALOGV("captureCallback: callbackInfo %p, visualizer_ref %p visualizer_class %p", callbackInfo, callbackInfo->visualizer_ref, callbackInfo->visualizer_class); - if (!user || !env) { - ALOGW("captureCallback error user %p, env %p", user, env); - return; - } + AutoMutex lock(&callbackInfo->callback_data_lock); if (waveformSize != 0 && waveform != NULL) { jbyteArray jArray; -- cgit v1.1