[FFmpeg-devel] [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context

Wujian(Chin) wujian2 at huawei.com
Wed Jun 15 14:14:39 EEST 2022


Signed-off-by: wujian_nanjing <wujian2 at huawei.com>
---
 libavcodec/v4l2_m2m.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index 51932ba..4427b48 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -251,7 +251,9 @@ static void v4l2_m2m_destroy_context(void *opaque, uint8_t *context)
     ff_v4l2_context_release(&s->capture);
     sem_destroy(&s->refsync);
 
-    close(s->fd);
+    if (s->fd >= 0)
+        close(s->fd);
+
     av_frame_unref(s->frame);
     av_frame_free(&s->frame);
     av_packet_unref(&s->buf_pkt);
-- 
2.7.4



More information about the ffmpeg-devel mailing list