From patchwork Wed Sep 4 22:08:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Potakhov X-Patchwork-Id: 14912 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 503FC447558 for ; Thu, 5 Sep 2019 01:08:31 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1FC4C687FD4; Thu, 5 Sep 2019 01:08:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw1-f43.google.com (mail-yw1-f43.google.com [209.85.161.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 70984687FCA for ; Thu, 5 Sep 2019 01:08:24 +0300 (EEST) Received: by mail-yw1-f43.google.com with SMTP id u141so14935ywe.4 for ; Wed, 04 Sep 2019 15:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=potahov.com; s=google; h=mime-version:from:date:message-id:subject:to; bh=bCZkG7ICg0PcAIvnFztJBlLX3H/OX/j38fkidKAp4iY=; b=gz53BjbKewFx+XGiQSWjsZiPq3cs3Nl7jV8MKf2+t+s/YvuCD+094XS7QnCTYC+QHL iEOEDuIIsvXmuOmpITHrttlpx7v9WppEqQFhFycFYSPW603ce5Xa5ZkkJkv3YuwC+P2X fkjfkJ1c0++MBGalpmSdM07BUc2p36fVYyqWQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=bCZkG7ICg0PcAIvnFztJBlLX3H/OX/j38fkidKAp4iY=; b=ldE0N9Z1/ERGWyvANe65GzCJKciogYmm1UbT77NjQf6p6LEFzrZ4OH3WRBS1ovdMpr lkdwF6Se/1BSdSxpZTdIxVk1FYY20ZjbwdDplIALrUh6oHLSdhfeWogcftjx5FvVke3T tzj+4EeEabUt+yMXF7NCkpXxXX6JBFn7EtEbO2e2+nJsHWeO9BpmdZOs4nAWefSsCgCU dhSDB6zYtNS/lPPKl5oSlHrBxx70Y6bCBuxg5n69e4QXA7a3SEf7fCmT3H1SJrRy+AsY d0eyiqjs5qYybns0qstE1e/gjewUsx19I6z0ECQmlvtElGEZeKD7C6L0sDcUBXzkumzg Obxw== X-Gm-Message-State: APjAAAWFZrPOOKsqdpOcJQZgCaP+APepX+XeNlThQq9AzsJYDEh6I5h4 kWkcOPl5FPXPUD+QTaGRSXTALHw3r0U+6bPiukE3K3VUVyX78Q== X-Google-Smtp-Source: APXvYqyYzKKRCCLnYNzaPsQs/3GvZhDKJ212q7CKMzF/Z31VddfpGCB3sGHtU7mZ4W3DndG94nuTtxvwxwU+pE3f2n4= X-Received: by 2002:a81:3e17:: with SMTP id l23mr93068ywa.312.1567634902733; Wed, 04 Sep 2019 15:08:22 -0700 (PDT) MIME-Version: 1.0 From: Alexey Potakhov Date: Wed, 4 Sep 2019 18:08:12 -0400 Message-ID: To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] Fixing rare dshow input crash X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 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);