From b07beb7bd768aad9a40f306a564b966b5bea95ef Mon Sep 17 00:00:00 2001 From: Emilian Peev Date: Thu, 7 Jan 2016 19:59:54 +0100 Subject: Snapdragon Camera: Check mosaic preview dimensions The preview dimensions used during the Mosaic libray initialization should be verified. Using invalid values like "0x0" could result in a crash of the JNI library. Change-Id: I812b9d1cb3cf6e664eaa582ee553d3af08d02bcb --- src/com/android/camera/WideAnglePanoramaModule.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/com/android') diff --git a/src/com/android/camera/WideAnglePanoramaModule.java b/src/com/android/camera/WideAnglePanoramaModule.java index 0b2880c37..06e9710f4 100644 --- a/src/com/android/camera/WideAnglePanoramaModule.java +++ b/src/com/android/camera/WideAnglePanoramaModule.java @@ -864,9 +864,14 @@ public class WideAnglePanoramaModule perct = mActivity.getResources().getInteger(R.integer.panorama_frame_size_reduction); } - mMosaicFrameProcessor.initialize(mCameraPreviewWidth * perct / 100, - mCameraPreviewHeight * perct / 100, getPreviewBufSize()); - mMosaicFrameProcessorInitialized = true; + int width = (mCameraPreviewWidth * perct) / 100; + int height = (mCameraPreviewHeight * perct) / 100; + if ((0 < width) && (0 < height)) { + mMosaicFrameProcessor.initialize(width, height, getPreviewBufSize()); + mMosaicFrameProcessorInitialized = true; + } else { + throw new RuntimeException("Invalid preview dimension"); + } } @Override -- cgit v1.2.3