From d8f3761cada5fc797124f40709e5379278473294 Mon Sep 17 00:00:00 2001 From: fryshorts Date: Tue, 15 Jul 2014 20:45:42 +0200 Subject: [PATCH] Fix a possibly left open file descriptor in v4l2 plugin --- plugins/linux-v4l2/v4l2-input.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/linux-v4l2/v4l2-input.c b/plugins/linux-v4l2/v4l2-input.c index 9717418e2..d4ab60ce2 100644 --- a/plugins/linux-v4l2/v4l2-input.c +++ b/plugins/linux-v4l2/v4l2-input.c @@ -299,16 +299,18 @@ static void v4l2_device_list(obs_property_t prop, obs_data_t settings) dstr_init_copy(&device, "/dev/"); while ((dp = readdir(dirp)) != NULL) { + if (dp->d_type == DT_DIR) + continue; + dstr_resize(&device, 5); dstr_cat(&device, dp->d_name); if ((fd = open(device.array, O_RDWR | O_NONBLOCK)) == -1) continue; - if (ioctl(fd, VIDIOC_QUERYCAP, &video_cap) == -1) - continue; - - if (video_cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) { + if (ioctl(fd, VIDIOC_QUERYCAP, &video_cap) == -1) { + + } else if (video_cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) { obs_property_list_add_string(prop, (char *) video_cap.card, device.array); @@ -318,6 +320,7 @@ static void v4l2_device_list(obs_property_t prop, obs_data_t settings) first = false; } } + close(fd); }