Motion - Bug Report 2007x 11x 26x 010755
You are here: Foswiki>Motion Web>BugReports>BugReport2007x11x26x010755 (18 May 2008, AngelCarpintero)Edit Attach

BUG: Uninitialized Struct in v4l_set_input

vid_tuner struct is not initialized in v4l_set_input which leads to random problems on some cards using the tuner. (see patch included)

--- video.c.dist        2007-11-25 19:51:58.000000000 -0500
+++ video.c     2007-11-25 19:52:16.000000000 -0500
@@ -326,7 +326,9 @@
        struct video_channel vid_chnl;
        struct video_tuner vid_tuner;
        unsigned long frequnits = freq;
-
+
+        memset(&vid_tuner, 0, sizeof(struct video_tuner));
+
        if (input != viddev->input || width != viddev->width || height!=viddev->height ||
            freq!=viddev->freq || tuner_number!=viddev->tuner_number) {
                if (freq) {

Environment

Motion version: 3.2.9
ffmpeg version:  
Shared libraries: ffmpeg, mysql, postgresql
Server OS:  

-- JasonSharpee - 26 Nov 2007

Follow up

Thanks Jason , i have improved your patch.

--- video.c     (revisión: 282)
+++ video.c     (copia de trabajo)
@@ -139,6 +139,7 @@
        }
 
        if (freq) {
+               memset(&vid_tuner, 0, sizeof(struct video_tuner));
                vid_tuner.tuner = tuner_number;
                if (ioctl (dev, VIDIOCGTUNER, &vid_tuner)==-1) {
                        motion_log(LOG_ERR, 1, "ioctl (VIDIOCGTUNER)");
@@ -329,6 +330,9 @@
        if (input != viddev->input || width != viddev->width || height!=viddev->height ||
            freq!=viddev->freq || tuner_number!=viddev->tuner_number) {
                if (freq) {
+
+                       memset(&vid_tuner, 0, sizeof(struct video_tuner));
+
                        vid_tuner.tuner = tuner_number;
                        if (ioctl (dev, VIDIOCGTUNER, &vid_tuner)==-1) {
                                motion_log(LOG_ERR, 1, "ioctl (VIDIOCGTUNER)");
@@ -345,6 +349,7 @@
                        }
                }
 
+               memset(&vid_chnl, 0, sizeof(struct video_channel));
                vid_chnl.channel = input;
 
                if (ioctl (dev, VIDIOCGCHAN, &vid_chnl) == -1) {

-- AngelCarpintero - 02 Dec 2007

Fix record

Thanks to pointing to this potencial problem , i have fixed some others missing initializations for video_tuner and video_channel.

-- AngelCarpintero - 02 Dec 2007
Topic revision: r4 - 18 May 2008, AngelCarpintero
Copyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.