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

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Tue Aug 3 17:22:41 EEST 2021


Diederick Niehorster:
> 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]) {
> 
Is this an issue that can also happen on current git master? If so, then
it should be the first of this whole series, so that it can be
backported to the still supported release branches. If not, then you
should incorporate this into the patch that introduces the crash in
order to make sure that it never exists (we do not knowingly commit bugs).

- Andreas


More information about the ffmpeg-devel mailing list