Fixed a couple of memory leaks in videoInput::getDevice() when multiple devices are present in the system

pull/11164/head
corley 7 years ago
parent 24acbecd33
commit f441515357
  1. 8
      modules/videoio/src/cap_dshow.cpp

@ -2912,7 +2912,7 @@ HRESULT videoInput::getDevice(IBaseFilter** gottaFilter, int deviceId, WCHAR * w
// Enumerate the monikers. // Enumerate the monikers.
IMoniker *pMoniker = NULL; IMoniker *pMoniker = NULL;
ULONG cFetched; ULONG cFetched;
while ((pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) && (!done)) while ((!done) && (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK))
{ {
if(deviceCounter == deviceId) if(deviceCounter == deviceId)
{ {
@ -2951,6 +2951,12 @@ HRESULT videoInput::getDevice(IBaseFilter** gottaFilter, int deviceId, WCHAR * w
pMoniker = NULL; pMoniker = NULL;
} }
} }
else
{
// cleaning for the case when this isn't the device we are looking for
pMoniker->Release();
pMoniker = NULL;
}
deviceCounter++; deviceCounter++;
} }
pEnumCat->Release(); pEnumCat->Release();

Loading…
Cancel
Save