From 8e7991a52edb3eb8bd1a44ceb7f6d97108748c8c Mon Sep 17 00:00:00 2001 From: Rajneesh Chowdury Date: Tue, 15 Mar 2011 16:20:17 -0700 Subject: Fix for 4087846 Crash reported by monkey report (Java/Jni) Change-Id: I356f975743f5a24e72f33a20ee497a2b12791be6 --- media/java/android/media/videoeditor/VideoEditorImpl.java | 12 ++++++++++++ media/jni/mediaeditor/VideoEditorMain.cpp | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/media/java/android/media/videoeditor/VideoEditorImpl.java b/media/java/android/media/videoeditor/VideoEditorImpl.java index 7e1f73aa88fc..608cea0e6cfe 100755 --- a/media/java/android/media/videoeditor/VideoEditorImpl.java +++ b/media/java/android/media/videoeditor/VideoEditorImpl.java @@ -899,6 +899,10 @@ public class VideoEditorImpl implements VideoEditor { throw new IllegalArgumentException("Surface could not be retrieved from Surface holder"); } + if (surface.isValid() == false) { + throw new IllegalStateException("Surface is not valid"); + } + if (timeMs < 0) { throw new IllegalArgumentException("requested time not correct"); } else if (timeMs > mDurationMs) { @@ -1622,6 +1626,10 @@ public class VideoEditorImpl implements VideoEditor { throw new IllegalArgumentException("Surface could not be retrieved from surface holder"); } + if (surface.isValid() == false) { + throw new IllegalStateException("Surface is not valid"); + } + if (listener == null) { throw new IllegalArgumentException(); } @@ -1858,6 +1866,10 @@ public class VideoEditorImpl implements VideoEditor { throw new IllegalArgumentException("Surface could not be retrieved from surface holder"); } + if (surface.isValid() == false) { + throw new IllegalStateException("Surface is not valid"); + } + if (mMANativeHelper != null) { mMANativeHelper.clearPreviewSurface(surface); } else { diff --git a/media/jni/mediaeditor/VideoEditorMain.cpp b/media/jni/mediaeditor/VideoEditorMain.cpp index 8cda14eee2e4..11e2a5eb076a 100755 --- a/media/jni/mediaeditor/VideoEditorMain.cpp +++ b/media/jni/mediaeditor/VideoEditorMain.cpp @@ -557,6 +557,10 @@ static void videoEditor_clearSurface(JNIEnv* pEnv, Surface* const p = (Surface*)pEnv->GetIntField(surface, surface_native); sp previewSurface = sp(p); + // Validate the mSurface's mNativeSurface field + videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv, + (NULL == previewSurface.get()), + "mNativeSurface is null"); frameStr.pBuffer = M4OSA_NULL; frameStr.timeMs = 0; @@ -634,6 +638,10 @@ static int videoEditor_renderPreviewFrame(JNIEnv* pEnv, Surface* const p = (Surface*)pEnv->GetIntField(mSurface, surface_native); sp previewSurface = sp(p); + // Validate the mSurface's mNativeSurface field + videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv, + (NULL == previewSurface.get()), + "mNativeSurface is null"); /* Determine the total number of clips, total duration*/ uiNumberOfClipsInStoryBoard = pContext->pEditSettings->uiClipNumber; @@ -2058,6 +2066,10 @@ videoEditor_startPreview( Surface* const p = (Surface*)pEnv->GetIntField(mSurface, surface_native); sp previewSurface = sp(p); + // Validate the mSurface's mNativeSurface field + videoEditJava_checkAndThrowIllegalStateException(&needToBeLoaded, pEnv, + (NULL == previewSurface.get()), + "mNativeSurface is null"); result = pContext->mPreviewController->setSurface(previewSurface); videoEditJava_checkAndThrowRuntimeException(&needToBeLoaded, pEnv, -- cgit v1.2.3-59-g8ed1b