[FFmpeg-devel] [PATCH] Fixing rare dshow input crash

Alexey Potakhov alex at potahov.com
Thu Sep 5 23:48:21 EEST 2019


re-sending without tabs.

On Wed, Sep 4, 2019 at 6:22 PM Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
>
> Am Do., 5. Sept. 2019 um 00:08 Uhr schrieb Alexey Potakhov <alex at potahov.com>:
>
> > In some rare cases when IAMStreamConfig_GetStreamCaps returns
> > an error avformat_open_input() crashes with access violation.
>
> Tabs are rejected by our repository, please remove them and resend.
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
-------------- next part --------------
From c15f00b4e70c60ac38009905b4d2c2f3032967a6 Mon Sep 17 00:00:00 2001
From: Alexey Potakhov <alex at 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(-)

diff --git a/libavdevice/dshow.c b/libavdevice/dshow.c
index d7f5bd7069..d1ae63b310 100644
--- a/libavdevice/dshow.c
+++ b/libavdevice/dshow.c
@@ -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);
-- 
2.21.0.windows.1



More information about the ffmpeg-devel mailing list