File ffmpeg-CVE-2020-22038.patch of Package ffmpeg.32491

diff --unified --recursive --text --new-file --color ffmpeg-3.4.2.old/libavcodec/v4l2_m2m.c ffmpeg-3.4.2.new/libavcodec/v4l2_m2m.c
--- ffmpeg-3.4.2.old/libavcodec/v4l2_m2m.c	2021-06-02 15:52:46.052175524 +0800
+++ ffmpeg-3.4.2.new/libavcodec/v4l2_m2m.c	2021-06-03 15:52:15.939579978 +0800
@@ -316,13 +316,18 @@
     V4L2m2mContext* s = avctx->priv_data;
     int ret;
 
-    ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF);
-    if (ret)
+    if (!s)
+        return 0;
+
+    if (s->fd >= 0) {
+        ret = ff_v4l2_context_set_status(&s->output, VIDIOC_STREAMOFF);
+        if (ret)
             av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->output.name);
 
-    ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF);
-    if (ret)
-        av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name);
+        ret = ff_v4l2_context_set_status(&s->capture, VIDIOC_STREAMOFF);
+        if (ret)
+            av_log(avctx, AV_LOG_ERROR, "VIDIOC_STREAMOFF %s\n", s->capture.name);
+    }
 
     ff_v4l2_context_release(&s->output);
 
openSUSE Build Service is sponsored by