[FFmpeg-devel] [PATCH v3 33/34] avdevice/dshow: prevent NULL access

Diederick Niehorster dcnieho at gmail.com
Tue Jul 6 12:20:19 EEST 2021


list_options true would crash when both a video and an audio device were
specified as input. Crash would occur on line 1588 (in this new rev)
because ctx->device_unique_name[otherDevType] would be NULL

Signed-off-by: Diederick Niehorster <dcnieho at gmail.com>
---
 libavdevice/dshow.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index f900e89988..a66f7b81fd 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -1519,9 +1519,9 @@ dshow_list_device_options(AVFormatContext *avctx, ICreateDevEnum *devenum,
     if ((r = dshow_cycle_devices(avctx, devenum, devtype, sourcetype, &device_filter, &device_unique_name, NULL)) < 0)
         return r;
     ctx->device_filter[devtype] = device_filter;
+    ctx->device_unique_name[devtype] = device_unique_name;
     if ((r = dshow_cycle_pins(avctx, devtype, sourcetype, device_filter, ranges ? &device_pin : NULL, ranges, query_type)) < 0)
         return r;
-    av_freep(&device_unique_name);
     return 0;
 }
 
@@ -2043,6 +2043,7 @@ static int dshow_read_header(AVFormatContext *avctx)
                 }
             }
         }
+        // don't exit yet, allow it to list crossbar options in dshow_open_device
     }
     ctx->is_running = 0;
     if (ctx->device_name[VideoDevice]) {
-- 
2.28.0.windows.1



More information about the ffmpeg-devel mailing list