From c4eb1940336cd88ca65ba65582ce104e49dfc7c9 Mon Sep 17 00:00:00 2001 From: Vaxry Date: Wed, 9 Oct 2024 22:00:06 +0100 Subject: [PATCH] gammactrl: guard pMonitor in setGamma --- src/protocols/GammaControl.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/protocols/GammaControl.cpp b/src/protocols/GammaControl.cpp index 077d6e2f..e794e543 100644 --- a/src/protocols/GammaControl.cpp +++ b/src/protocols/GammaControl.cpp @@ -46,6 +46,13 @@ CGammaControl::CGammaControl(SP resource_, wl_resource* out resource->setOnDestroy([this](CZwlrGammaControlV1* gamma) { PROTO::gamma->destroyGammaControl(this); }); resource->setSetGamma([this](CZwlrGammaControlV1* gamma, int32_t fd) { + if (!pMonitor) { + LOGM(ERR, "setGamma for a dead monitor"); + resource->sendFailed(); + close(fd); + return; + } + LOGM(LOG, "setGamma for {}", pMonitor->szName); int fdFlags = fcntl(fd, F_GETFL, 0);