[FFmpeg-devel] [PATCH] libavcodec\v4l2_m2m.c: avcodec/v4l2_m2m: Check if the file descriptor is valid before closing//答复: 答复: [PATCH] avcodec/v4l2_m2m: close the invalid file descriptor -1 in function v4l2_m2m_destroy_context

Wujian(Chin) wujian2 at huawei.com
Mon Jun 27 15:32:16 EEST 2022


Fixes ticket #9507.

Signed-off-by: wujian_nanjing <wujian2 at huawei.com>
---
 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 51932ba..9849360 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);
-- 
2.7.4
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-libavcodec-v4l2_m2m.c-avcodec-v4l2_m2m-Check-if-the-.patch
Type: application/octet-stream
Size: 829 bytes
Desc: 0001-libavcodec-v4l2_m2m.c-avcodec-v4l2_m2m-Check-if-the-.patch
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220627/44876ca2/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ATT00001.txt
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20220627/44876ca2/attachment.txt>


More information about the ffmpeg-devel mailing list