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

Wujian(Chin) wujian2 at huawei.com
Sat Jun 25 06:04:59 EEST 2022


Hi:
Please review it.
Thks!

-----邮件原件-----
发件人: Wujian(Chin) 
发送时间: 2022年6月15日 19:15
收件人: 'ffmpeg-devel at ffmpeg.org' <ffmpeg-devel at ffmpeg.org>
主题: [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context

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