From b885f358a51d1ea6b126372a3d122b26c19dbe46 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 26 Apr 2021 21:33:51 +0200 Subject: [PATCH] output/control: add missing nullptr checks Fixes crash when pausing the default partition after an output was moved to another partition. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1147 --- NEWS | 1 + src/output/Control.cxx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index f72f15838..a9a846f70 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,7 @@ ver 0.22.7 (not yet released) * database - simple: fix database corruption bug * output + - fix crash when pausing with multiple partitions - httpd: send header "Access-Control-Allow-Origin: *" - wasapi: add algorithm for finding usable audio format - wasapi: use default device only if none was configured diff --git a/src/output/Control.cxx b/src/output/Control.cxx index 6141710e4..625c6ff37 100644 --- a/src/output/Control.cxx +++ b/src/output/Control.cxx @@ -118,7 +118,7 @@ AudioOutputControl::GetLogName() const noexcept { assert(!IsDummy()); - return output->GetLogName(); + return output ? output->GetLogName() : name.c_str(); } Mixer * @@ -364,7 +364,7 @@ AudioOutputControl::LockPlay() noexcept void AudioOutputControl::LockPauseAsync() noexcept { - if (output->mixer != nullptr && !output->SupportsPause()) + if (output && output->mixer != nullptr && !output->SupportsPause()) /* the device has no pause mode: close the mixer, unless its "global" flag is set (checked by mixer_auto_close()) */