From c011bd20886ea3301474e77d7fa4d22ab013ece0 Mon Sep 17 00:00:00 2001 From: Kioz <49008623+kioz-wang@users.noreply.github.com> Date: Mon, 25 May 2026 23:27:25 +0800 Subject: [PATCH] internal: fix missing null check for g_IPCSocket in onRepeatTimer (#368) CWallpaperTarget::onRepeatTimer() calls IPC::g_IPCSocket->onWallpaperChanged() without checking if g_IPCSocket is valid. When IPC is disabled (ipc=0) or not initialized, g_IPCSocket is nullptr, causing a SIGSEGV. Stack trace from coredump: #0 __normal_iterator constructor (this->m_statusObjects at 0x60) #1 IPC::CSocket::onWallpaperChanged (this=0x0) #2 CWallpaperTarget::onRepeatTimer GDB confirms this=0x0 in onWallpaperChanged, meaning g_IPCSocket.get() returned nullptr when dereferenced. Fix: add a null guard matching the pattern already used in registerOutput() and elsewhere in the codebase. --- src/ui/UI.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/UI.cpp b/src/ui/UI.cpp index 71308af..04c5535 100644 --- a/src/ui/UI.cpp +++ b/src/ui/UI.cpp @@ -140,7 +140,8 @@ void CWallpaperTarget::onRepeatTimer() { m_timer = m_backend->addTimer(std::chrono::milliseconds(std::chrono::seconds(m_imagesData->timeout)), [this](ASP self, void*) { onRepeatTimer(); }, nullptr); - IPC::g_IPCSocket->onWallpaperChanged(m_monitorName, m_lastPath); + if (IPC::g_IPCSocket) + IPC::g_IPCSocket->onWallpaperChanged(m_monitorName, m_lastPath); } void CUI::registerOutput(const SP& mon) {