v4l2: Make sure v4l2_format stack variable is initialized
authorBenoit Parrot <bparrot@ti.com>
Mon, 24 Jul 2017 19:23:10 +0000 (19:23 +0000)
committerNikhil Devshatwar <nikhil.nd@ti.com>
Wed, 26 Jul 2017 08:12:59 +0000 (13:42 +0530)
When using v4l2_format variable allocated on the stack make
sure it is zeroed-out to prevent unexpected behavior.

Signed-off-by: Benoit Parrot <bparrot@ti.com>
util/v4l2.c

index 7d16eafa41e499f40d8010b041dc568c50285948..f844ba44f735557e2548b9bb1b1178c2188e9bc3 100644 (file)
@@ -278,6 +278,8 @@ v4l2_open(int argc, char **argv, uint32_t *fourcc,
 
        v4l2->fd = open(devname, O_RDWR);
 
+       memset(&format, 0, sizeof(format));
+       format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        ret = ioctl(v4l2->fd, VIDIOC_G_FMT, &format);
        if (ret < 0) {
                ERROR("VIDIOC_G_FMT failed: %s (%d)", strerror(errno), ret);