From 683fc77f80e6ba32cd3cff04fccdc95f7a9308a1 Mon Sep 17 00:00:00 2001 From: Tom Englund Date: Thu, 25 Sep 2025 01:44:07 +0200 Subject: [PATCH] hyprctl: nullptr guard --systeminfo (#11822) running Hyprland --systeminfo from a console/tty calls systemInfoRequest without us having a g_pCompositor or g_pHyprOpengl, so just if check them and make --systeminfo not segfault and atleast print what info we can. --- src/debug/HyprCtl.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp index 26cc8d14c..0c34c375f 100644 --- a/src/debug/HyprCtl.cpp +++ b/src/debug/HyprCtl.cpp @@ -1180,19 +1180,24 @@ std::string systemInfoRequest(eHyprCtlOutputFormat format, std::string request) } else result += "\tunknown: not runtime\n"; - result += std::format("\nExplicit sync: {}", g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext ? "supported" : "missing"); - result += std::format("\nGL ver: {}", g_pHyprOpenGL->m_eglContextVersion == CHyprOpenGLImpl::EGL_CONTEXT_GLES_3_2 ? "3.2" : "3.0"); - result += std::format("\nBackend: {}", g_pCompositor->m_aqBackend->hasSession() ? "drm" : "sessionless"); + if (g_pHyprOpenGL) { + result += std::format("\nExplicit sync: {}", g_pHyprOpenGL->m_exts.EGL_ANDROID_native_fence_sync_ext ? "supported" : "missing"); + result += std::format("\nGL ver: {}", g_pHyprOpenGL->m_eglContextVersion == CHyprOpenGLImpl::EGL_CONTEXT_GLES_3_2 ? "3.2" : "3.0"); + } - result += "\n\nMonitor info:"; + if (g_pCompositor) { + result += std::format("\nBackend: {}", g_pCompositor->m_aqBackend->hasSession() ? "drm" : "sessionless"); - for (const auto& m : g_pCompositor->m_monitors) { - result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable " - "{}\n\t\tnon-desktop {}\n\t\t", - m->m_name, sc(m->m_pixelSize.x), sc(m->m_pixelSize.y), m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial, - backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()), - check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable), - check(m->m_output->nonDesktop)); + result += "\n\nMonitor info:"; + + for (const auto& m : g_pCompositor->m_monitors) { + result += std::format("\n\tPanel {}: {}x{}, {} {} {} {} -> backend {}\n\t\texplicit {}\n\t\tedid:\n\t\t\thdr {}\n\t\t\tchroma {}\n\t\t\tbt2020 {}\n\t\tvrr capable " + "{}\n\t\tnon-desktop {}\n\t\t", + m->m_name, sc(m->m_pixelSize.x), sc(m->m_pixelSize.y), m->m_output->name, m->m_output->make, m->m_output->model, m->m_output->serial, + backend(m->m_output->getBackend()->type()), check(m->m_output->supportsExplicit), check(m->m_output->parsedEDID.hdrMetadata.has_value()), + check(m->m_output->parsedEDID.chromaticityCoords.has_value()), check(m->m_output->parsedEDID.supportsBT2020), check(m->m_output->vrrCapable), + check(m->m_output->nonDesktop)); + } } if (g_pHyprCtl && g_pHyprCtl->m_currentRequestParams.sysInfoConfig) {