From 4d6ae6ffdde6132551107be63e47549ef595ad02 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 8 Jul 2022 11:27:17 +0200 Subject: [PATCH] output/PipeWire: add nullptr check to SetVolume() If the PipeWire output has not yet been enabled and no thread_loop has been created yet, a nullptr dereference in SetVolume() was possible because nullptr was passed to pw_thread_loop_lock(). --- NEWS | 1 + src/output/plugins/PipeWireOutputPlugin.cxx | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/NEWS b/NEWS index cb25c1a0e..c221a6669 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,7 @@ ver 0.23.8 (not yet released) * mixer - better error messages - alsa: fix setting volume before playback starts + - pipewire: fix crash bug * support libfmt 9 ver 0.23.7 (2022/05/09) diff --git a/src/output/plugins/PipeWireOutputPlugin.cxx b/src/output/plugins/PipeWireOutputPlugin.cxx index c752820d0..c407dd3c1 100644 --- a/src/output/plugins/PipeWireOutputPlugin.cxx +++ b/src/output/plugins/PipeWireOutputPlugin.cxx @@ -312,6 +312,14 @@ PipeWireOutput::PipeWireOutput(const ConfigBlock &block) void PipeWireOutput::SetVolume(float _volume) { + if (thread_loop == nullptr) { + /* the mixer is open (because it is a "global" mixer), + but Enable() on this output has not yet been + called */ + volume = _volume; + return; + } + const PipeWire::ThreadLoopLock lock(thread_loop); float newvol = _volume*_volume*_volume;