aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2011-10-21 18:22:06 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2011-10-21 18:22:06 -0700
commit79570c3532503840855517494978082a99543a30 (patch)
treefaac6877f8e80cb83603d24a37b93cdb276c1286
parent04d90d093f6e552c8c0c77f8d4a08344c77a4fca (diff)
downloadexternal_qemu-79570c3532503840855517494978082a99543a30.zip
external_qemu-79570c3532503840855517494978082a99543a30.tar.gz
external_qemu-79570c3532503840855517494978082a99543a30.tar.bz2
Fix emulator crash.
Change-Id: I4f238bbd0175036b6003ebdf266de608d6acc6e7
-rw-r--r--android/camera/camera-capture-linux.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/android/camera/camera-capture-linux.c b/android/camera/camera-capture-linux.c
index b9a4227..5243fb6 100644
--- a/android/camera/camera-capture-linux.c
+++ b/android/camera/camera-capture-linux.c
@@ -670,15 +670,16 @@ _camera_device_enum_format_sizes(LinuxCameraDevice* cd,
static int
_camera_device_enum_pixel_formats(LinuxCameraDevice* cd, QemuPixelFormat** fmts)
{
- int n;
+ int n, max_fmt;
int fmt_num = 0;
int out_num = 0;
struct v4l2_fmtdesc fmt_enum;
QemuPixelFormat* arr;
/* Calculate number of supported formats. */
- for (n = 0; ; n++) {
- fmt_enum.index = n;
+ for (max_fmt = 0; ; max_fmt++) {
+ memset(&fmt_enum, 0, sizeof(fmt_enum));
+ fmt_enum.index = max_fmt;
fmt_enum.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(_xioctl(cd->handle, VIDIOC_ENUM_FMT, &fmt_enum)) {
break;
@@ -700,7 +701,8 @@ _camera_device_enum_pixel_formats(LinuxCameraDevice* cd, QemuPixelFormat** fmts)
}
arr = *fmts;
memset(arr, 0, fmt_num * sizeof(QemuPixelFormat));
- for (n = 0; n < fmt_num && out_num < fmt_num; n++) {
+ for (n = 0; n < max_fmt && out_num < fmt_num; n++) {
+ memset(&fmt_enum, 0, sizeof(fmt_enum));
fmt_enum.index = n;
fmt_enum.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(_xioctl(cd->handle, VIDIOC_ENUM_FMT, &fmt_enum)) {
@@ -757,7 +759,7 @@ _camera_device_get_info(LinuxCameraDevice* cd, CameraInfo* cis)
QemuPixelFormat* formats = NULL;
int num_pix_fmts = _camera_device_enum_pixel_formats(cd, &formats);
if (num_pix_fmts <= 0) {
- return num_pix_fmts;
+ return -1;
}
/* Lets see if camera supports preferred formats */