main: Initialise stream object to NULL
authorKieran Bingham <kieran.bingham@ideasonboard.com>
Tue, 28 Aug 2018 14:30:08 +0000 (15:30 +0100)
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Thu, 30 Aug 2018 21:45:33 +0000 (00:45 +0300)
If the capture device fails to load the default cleanup path will be
taken.  This error path relies on objects either existing or being set
to NULL.

Ensure that the stream pointer is initialised to prevent segfaults on
the error path.

Fixes: 1b8f9204db68 ("stream: Use abstract video sources")
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reiewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
main.c

diff --git a/main.c b/main.c
index 7b1c825..00857f6 100644 (file)
--- a/main.c
+++ b/main.c
@@ -58,7 +58,7 @@ int main(int argc, char *argv[])
        char *function = NULL;
        char *cap_device = "/dev/video1";
        struct uvc_function_config *fc;
-       struct uvc_stream *stream;
+       struct uvc_stream *stream = NULL;
        struct video_source *src = NULL;
        struct events events;
        int ret = 0;