diff --git a/include/modules/mpd.hpp b/include/modules/mpd.hpp index bd010020..3e94bee8 100644 --- a/include/modules/mpd.hpp +++ b/include/modules/mpd.hpp @@ -64,6 +64,12 @@ namespace modules { static constexpr const char* EVENT_SEEK{"mpdseek"}; unique_ptr m_mpd; + + /* + * Stores the mpdstatus instance for the current connection + * m_status is not initialized if mpd is not connect, you always have to + * make sure that m_status is not NULL before dereferencing it + */ unique_ptr m_status; string m_host{"127.0.0.1"}; diff --git a/src/modules/mpd.cpp b/src/modules/mpd.cpp index 3d67bc3b..515d402b 100644 --- a/src/modules/mpd.cpp +++ b/src/modules/mpd.cpp @@ -200,7 +200,7 @@ namespace modules { } } - if (m_status->match_state(mpdstate::PLAYING)) { + if (m_status && m_status->match_state(mpdstate::PLAYING)) { // Always update the status while playing m_status->update(-1, m_mpd.get()); }