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

Signed-off-by: Diederick Niehorster <dcni...@gmail.com>
---
 libavdevice/dshow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index c158a536d8..9af3360317 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -1503,9 +1503,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;
 }
 
@@ -1565,7 +1565,8 @@ dshow_open_device(AVFormatContext *avctx, ICreateDevEnum 
*devenum,
             goto error;
         }
     }
-        if (ctx->device_filter[otherDevType]) {
+    
+    if (ctx->device_filter[otherDevType]) {
         // avoid adding add two instances of the same device to the graph, one 
for video, one for audio
         // a few devices don't support this (could also do this check earlier 
to avoid double crossbars, etc. but they seem OK)
         if (strcmp(device_filter_unique_name, 
ctx->device_unique_name[otherDevType]) == 0) {
@@ -2027,6 +2028,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

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to