[FFmpeg-cvslog] avcodec/v4l2_context: suppress POLLERR and fix crash when buffers are uninitialized

Richard Acayan git at videolan.org
Thu Jul 27 22:24:11 EEST 2023


ffmpeg | branch: master | Richard Acayan <mailingradian at gmail.com> | Tue Jul 25 17:38:39 2023 -0400| [4fa1d3e7910c3fbe3aacbe5ae5233d0067569c02] | committer: Marton Balint

avcodec/v4l2_context: suppress POLLERR and fix crash when buffers are uninitialized

A POLLERR occurs when libavcodec attempts to dequeue output buffers
before enqueuing capture buffers. This could happen to an application
deciding to send the first coded packet. Suppress these POLLERRs when
the buffers are uninitialized and avoid crashing because of enumerating
uninitialized buffers.

See https://trac.ffmpeg.org/ticket/9957 for the original bug report.

Signed-off-by: Richard Acayan <mailingradian at gmail.com>
Signed-off-by: Marton Balint <cus at passwd.hu>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4fa1d3e7910c3fbe3aacbe5ae5233d0067569c02
---

 libavcodec/v4l2_context.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c
index a40be94690..f20f713e1d 100644
--- a/libavcodec/v4l2_context.c
+++ b/libavcodec/v4l2_context.c
@@ -325,9 +325,13 @@ start:
 
     /* 0. handle errors */
     if (pfd.revents & POLLERR) {
-        /* if we are trying to get free buffers but none have been queued yet
-           no need to raise a warning */
+        /* if we are trying to get free buffers but none have been queued yet,
+         * or if no buffers have been allocated yet, no need to raise a warning
+         */
         if (timeout == 0) {
+            if (!ctx->buffers)
+                return NULL;
+
             for (i = 0; i < ctx->num_buffers; i++) {
                 if (ctx->buffers[i].status != V4L2BUF_AVAILABLE)
                     av_log(logger(ctx), AV_LOG_WARNING, "%s POLLERR\n", ctx->name);



More information about the ffmpeg-cvslog mailing list