diff mbox series

[FFmpeg-devel,34/35] avdevice/dshow: prevent NULL access

Message ID 20210607230414.612-35-dcnieho@gmail.com
State Superseded, archived
Headers show
Series avdevice (mostly dshow) enhancements
Related show

Checks

Context Check Description
andriy/x86_make fail Make failed
andriy/PPC64_make warning Make failed

Commit Message

Diederick C. Niehorster June 7, 2021, 11:04 p.m. UTC
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 <dcnieho@gmail.com>
---
 libavdevice/dshow.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox series

Patch

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]) {