From dcb334ff8120bde81643b906748c8421a330481a Mon Sep 17 00:00:00 2001 From: klemek Date: Sat, 16 May 2026 18:22:48 +0200 Subject: [PATCH] fix: handle VIDIOC_QBUF error while reading video --- src/video.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/video.c b/src/video.c index c95cf64..38072af 100644 --- a/src/video.c +++ b/src/video.c @@ -306,11 +306,15 @@ static unsigned int read_video(VideoCapture *video_capture) { if (ioctl(video_capture->fd, VIDIOC_DQBUF, &video_capture->buf[video_capture->buf_index]) != -1) { - ioctl(video_capture->fd, VIDIOC_QBUF, - &video_capture->buf[video_capture->buf_index]); - video_capture->buf_index = - (video_capture->buf_index + 1) % video_capture->buf_count; - return true; + if (ioctl(video_capture->fd, VIDIOC_QBUF, + &video_capture->buf[video_capture->buf_index]) == -1) { + video_capture->error = true; + return false; + } else { + video_capture->buf_index = + (video_capture->buf_index + 1) % video_capture->buf_count; + return true; + } } if (ioctl(video_capture->fd, VIDIOC_QUERYCAP, &cap) == -1) {