[FFmpeg-cvslog] avcodec/v4l2_m2m: Check if the file descriptor is valid before closing

Wujian(Chin) git at videolan.org
Fri Jul 1 05:00:02 EEST 2022


ffmpeg | branch: master | Wujian(Chin) <wujian2 at huawei.com> | Tue Jun 28 11:15:12 2022 +0000| [26e7d7b14e7a3912aa0ce59ebab191a9c2d9edfa] | committer: Steven Liu

avcodec/v4l2_m2m: Check if the file descriptor is valid before closing

Fixes ticket #9507.

Reviewed-by: Steven Liu <liuqi05 at kuaishou.com>
Signed-off-by: wujian_nanjing <wujian2 at huawei.com>

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

 libavcodec/v4l2_m2m.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/v4l2_m2m.c b/libavcodec/v4l2_m2m.c
index 51932baf84..984936004d 100644
--- a/libavcodec/v4l2_m2m.c
+++ b/libavcodec/v4l2_m2m.c
@@ -251,7 +251,8 @@ 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);



More information about the ffmpeg-cvslog mailing list