From 2006424e211114d8bfdaaf8891d7889a2fc25c7a Mon Sep 17 00:00:00 2001 From: ValdikSS ValdikSS Date: Sat, 17 Sep 2022 15:54:11 +0300 Subject: [PATCH] Prevent null pointer dereference if there's no audio devices BUG: 454917 --- plugins/systemvolume/systemvolumeplugin-win.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/systemvolume/systemvolumeplugin-win.cpp b/plugins/systemvolume/systemvolumeplugin-win.cpp index 33eaa60e2..548017a2c 100644 --- a/plugins/systemvolume/systemvolumeplugin-win.cpp +++ b/plugins/systemvolume/systemvolumeplugin-win.cpp @@ -252,9 +252,19 @@ bool SystemvolumePlugin::sendSinkList() unsigned int deviceCount; devices->GetCount(&deviceCount); + if (!deviceCount) { + qWarning("No audio devices detected"); + return false; + } + IMMDevice *defaultDevice = nullptr; deviceEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &defaultDevice); + if (!defaultDevice) { + qWarning("No default audio device detected"); + return false; + } + LPWSTR defaultId = NULL; defaultDevice->GetId(&defaultId);