From 524ff6fe27cfb0a2f2154b1543134d0e93784c6b Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Fri, 17 Aug 2012 23:04:31 +0200 Subject: [PATCH] qcap: Fixed a use after free in error path (Coverity). --- dlls/qcap/v4l.c | 1 + dlls/qcap/vfwcapture.c | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/qcap/v4l.c b/dlls/qcap/v4l.c index 119eb294da3..1851ba451cc 100644 --- a/dlls/qcap/v4l.c +++ b/dlls/qcap/v4l.c @@ -314,6 +314,7 @@ HRESULT qcap_driver_get_format(const Capture *capBox, AM_MEDIA_TYPE ** mT) if (!vi) { CoTaskMemFree(mT[0]); + mT[0] = NULL; return E_OUTOFMEMORY; } mT[0]->majortype = MEDIATYPE_Video; diff --git a/dlls/qcap/vfwcapture.c b/dlls/qcap/vfwcapture.c index 68341ae8eb5..7be59cc0f2c 100644 --- a/dlls/qcap/vfwcapture.c +++ b/dlls/qcap/vfwcapture.c @@ -678,9 +678,10 @@ static HRESULT WINAPI VfwPin_GetMediaType(BasePin *iface, int iPosition, AM_MEDI return VFW_S_NO_MORE_ITEMS; hr = qcap_driver_get_format(This->driver_info, &vfw_pmt); - CopyMediaType(pmt, vfw_pmt); - DeleteMediaType(vfw_pmt); - + if (SUCCEEDED(hr)) { + CopyMediaType(pmt, vfw_pmt); + DeleteMediaType(vfw_pmt); + } return hr; }