From 42b5e68cf00a55230f39cd75fdbc3df2d2738f68 Mon Sep 17 00:00:00 2001 From: Edric Milaret <edric.ladent-milaret@savoirfairelinux.com> Date: Mon, 27 Apr 2015 09:42:21 -0400 Subject: [PATCH] windows: fix SIGSEGV occuring when no camera are found Refs #71985 Change-Id: I78aa51ef823a2d48da96d4f0ed58bc838915b4f5 --- src/media/video/winvideo/video_device_monitor_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/media/video/winvideo/video_device_monitor_impl.cpp b/src/media/video/winvideo/video_device_monitor_impl.cpp index e66624e29b..330c565432 100644 --- a/src/media/video/winvideo/video_device_monitor_impl.cpp +++ b/src/media/video/winvideo/video_device_monitor_impl.cpp @@ -105,17 +105,17 @@ VideoDeviceMonitorImpl::run() hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pDevEnum)); - IEnumMoniker *pEnum; + IEnumMoniker *pEnum = nullptr; if (SUCCEEDED(hr)) { hr = pDevEnum->CreateClassEnumerator( CLSID_VideoInputDeviceCategory, &pEnum, 0); - if (FAILED(hr)) { + pDevEnum->Release(); + if (FAILED(hr) || pEnum == nullptr) { RING_ERR("No webcam found."); hr = VFW_E_NOT_FOUND; } - pDevEnum->Release(); - if (hr != VFW_E_NOT_FOUND) { + if (hr != VFW_E_NOT_FOUND && pEnum != nullptr) { IMoniker *pMoniker = NULL; unsigned deviceID = 0; while (pEnum->Next(1, &pMoniker, NULL) == S_OK) -- GitLab