@@ -340,8 +340,10 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype,
for (i = 0; i < n && !format_set; i++) {
r = IAMStreamConfig_GetStreamCaps(config, i, &type, (void *) caps);
- if (r != S_OK)
- goto next;
+ if (r != S_OK) {
+ type = NULL;
+ goto next;
+ }
#if DSHOWDEBUG
ff_print_AM_MEDIA_TYPE(type);
#endif
@@ -450,9 +452,11 @@ dshow_cycle_formats(AVFormatContext *avctx, enum dshowDeviceType devtype,
goto next;
format_set = 1;
next:
- if (type->pbFormat)
- CoTaskMemFree(type->pbFormat);
- CoTaskMemFree(type);
+ if (type) {
+ if (type->pbFormat)
+ CoTaskMemFree(type->pbFormat);
+ CoTaskMemFree(type);
+ }
}
end:
IAMStreamConfig_Release(config);
In some rare cases when IAMStreamConfig_GetStreamCaps returns an error avformat_open_input() crashes with access violation. From c15f00b4e70c60ac38009905b4d2c2f3032967a6 Mon Sep 17 00:00:00 2001 From: Alexey Potakhov <alex@potahov.com> Date: Wed, 4 Sep 2019 17:54:24 -0400 Subject: [PATCH] Fixing rare dshow input crash --- libavdevice/dshow.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)