Skip to content
Snippets Groups Projects
Commit 42b5e68c authored by Edric Milaret's avatar Edric Milaret Committed by Guillaume Roguez
Browse files

windows: fix SIGSEGV occuring when no camera are found

Refs #71985

Change-Id: I78aa51ef823a2d48da96d4f0ed58bc838915b4f5
parent 85a890d0
No related branches found
No related tags found
No related merge requests found
...@@ -105,17 +105,17 @@ VideoDeviceMonitorImpl::run() ...@@ -105,17 +105,17 @@ VideoDeviceMonitorImpl::run()
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum)); CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum));
IEnumMoniker *pEnum; IEnumMoniker *pEnum = nullptr;
if (SUCCEEDED(hr)) { if (SUCCEEDED(hr)) {
hr = pDevEnum->CreateClassEnumerator( hr = pDevEnum->CreateClassEnumerator(
CLSID_VideoInputDeviceCategory, CLSID_VideoInputDeviceCategory,
&pEnum, 0); &pEnum, 0);
if (FAILED(hr)) { pDevEnum->Release();
if (FAILED(hr) || pEnum == nullptr) {
RING_ERR("No webcam found."); RING_ERR("No webcam found.");
hr = VFW_E_NOT_FOUND; hr = VFW_E_NOT_FOUND;
} }
pDevEnum->Release(); if (hr != VFW_E_NOT_FOUND && pEnum != nullptr) {
if (hr != VFW_E_NOT_FOUND) {
IMoniker *pMoniker = NULL; IMoniker *pMoniker = NULL;
unsigned deviceID = 0; unsigned deviceID = 0;
while (pEnum->Next(1, &pMoniker, NULL) == S_OK) while (pEnum->Next(1, &pMoniker, NULL) == S_OK)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment