From 2c95a4e6b9add636bb2398e8656268c399f97f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=C4=8Cuki=C4=87?= Date: Fri, 8 Apr 2016 09:25:02 +0200 Subject: [PATCH] Checking whether m_topLevel is not null before getting its property Summary: From the rest of this method, it is obvious that m_topLevel can be null in any part of the method - we are checking against it being null in a few places in the method - both before and after the affending lines. Now, there is one place where the check is not applied, and potentially calls ->window() on the null pointer. p.s. If there are more places where kwin does clear_or_something(); return; it could benefit from introducing on_scope_exit and similar tricks - see Alexandrescu's 'Declarative control flow' presentation. Reviewers: graesslin Reviewed By: graesslin Subscribers: plasma-devel Projects: #plasma Differential Revision: https://phabricator.kde.org/D1346 --- shadow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shadow.cpp b/shadow.cpp index 65b4080914..76792ad8bd 100644 --- a/shadow.cpp +++ b/shadow.cpp @@ -365,6 +365,10 @@ bool Shadow::updateShadow() } } } + if (!m_topLevel) { + clear(); + return false; + } auto data = Shadow::readX11ShadowProperty(m_topLevel->window()); if (data.isEmpty()) { clear();