From d7240d1a28b9f09da5769b49ea8a4059a99d9e2e Mon Sep 17 00:00:00 2001 From: berak Date: Tue, 21 Feb 2017 14:27:12 +0100 Subject: [PATCH] fix leaking handle in cap_dshow.cpp --- modules/videoio/src/cap_dshow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/videoio/src/cap_dshow.cpp b/modules/videoio/src/cap_dshow.cpp index 8360e4318b..200edc71c1 100644 --- a/modules/videoio/src/cap_dshow.cpp +++ b/modules/videoio/src/cap_dshow.cpp @@ -877,14 +877,12 @@ void videoDevice::NukeDownstream(IBaseFilter *pBF){ void videoDevice::destroyGraph(){ HRESULT hr = 0; - //int FuncRetval=0; - //int NumFilters=0; int i = 0; while (hr == NOERROR) { IEnumFilters * pEnum = 0; - ULONG cFetched; + ULONG cFetched = 0; // We must get the enumerator again every time because removing a filter from the graph // invalidates the enumerator. We always get only the first filter from each enumerator. @@ -917,9 +915,11 @@ void videoDevice::destroyGraph(){ pFilter->Release(); pFilter = NULL; } - else break; pEnum->Release(); pEnum = NULL; + + if (cFetched == 0) + break; i++; }