summaryrefslogtreecommitdiff
authorFrank Chen <frank.chen@amlogic.com>2015-07-02 09:57:42 (GMT)
committer Frank Chen <frank.chen@amlogic.com>2015-07-02 09:57:42 (GMT)
commit145d68a78458287f6655a64b00158913bc5f95a7 (patch)
tree6cf0ced5c92528b43e0b64ca51b2b5544172a350
parent860e1e865f31cd7b7cd424e4af06898a178028f9 (diff)
downloadcamera-145d68a78458287f6655a64b00158913bc5f95a7.zip
camera-145d68a78458287f6655a64b00158913bc5f95a7.tar.gz
camera-145d68a78458287f6655a64b00158913bc5f95a7.tar.bz2
fix crash in camera.amlogic.so
Change-Id: Ibc33831479bb5bbc8089deb1972049095bde00f8
Diffstat
-rwxr-xr-xv3/EmulatedCameraFactory.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/v3/EmulatedCameraFactory.cpp b/v3/EmulatedCameraFactory.cpp
index d857da2..ea25c91 100755
--- a/v3/EmulatedCameraFactory.cpp
+++ b/v3/EmulatedCameraFactory.cpp
@@ -420,6 +420,12 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
const camera_module_callbacks_t* cb = mCallbacks;
sprintf(dev_name, "%s%d", "/dev/video", cameraId);
+ /* ignore cameraid >= MAX_CAMERA_NUM to avoid overflow, we now have
+ * ion device with device like /dev/video13
+ */
+ if (cameraId >= MAX_CAMERA_NUM)
+ return;
+
CAMHAL_LOGDB("mEmulatedCameraNum =%d\n", mEmulatedCameraNum);
/*we release mEmulatedCameras[i] object for the last time construct*/
@@ -436,8 +442,8 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
if (!cam) {
/*suppose only usb camera produce uevent, and it is facing back*/
cam = new EmulatedFakeCamera3(cameraId, &HAL_MODULE_INFO_SYM.common);
- cam->setCameraStatus(CAMERA_INIT);
if (cam != NULL) {
+ cam->setCameraStatus(CAMERA_INIT);
CAMHAL_LOGDB("%s: new camera device version is %d", __FUNCTION__,
getFakeCameraHalVersion(cameraId));
//sleep 10ms for /dev/video* create
@@ -459,16 +465,15 @@ void EmulatedCameraFactory::onStatusChanged(int cameraId, int newStatus)
delete cam;
return ;
}
- }
- /* Open the camera. then send the callback to framework*/
- mEmulatedCameras[cameraId] = cam;
- mEmulatedCameraNum ++;
- cam->plugCamera();
- if (cb != NULL && cb->camera_device_status_change != NULL) {
- cb->camera_device_status_change(cb, cameraId, newStatus);
+ /* Open the camera. then send the callback to framework*/
+ mEmulatedCameras[cameraId] = cam;
+ mEmulatedCameraNum ++;
+ cam->plugCamera();
+ if (cb != NULL && cb->camera_device_status_change != NULL) {
+ cb->camera_device_status_change(cb, cameraId, newStatus);
+ }
}
-
return ;
}