From 21c891e6691ba20c144c17e96a1970efcfcb60ec Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 18 May 2014 21:31:48 +0200 Subject: [PATCH] WINGs: fix possible NULL pointer dereference in WMFreeColorPanel (Coverity #50189) As pointed by Coverity, the code was checking for NULL pointer to avoid misbehaviour, but it actually dereferenced the pointer beforehand so the crash would still happen. Signed-off-by: Christophe CURIS --- WINGs/wcolorpanel.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/WINGs/wcolorpanel.c b/WINGs/wcolorpanel.c index b61b336a..60655cdf 100644 --- a/WINGs/wcolorpanel.c +++ b/WINGs/wcolorpanel.c @@ -1097,15 +1097,16 @@ WMColorPanel *WMGetColorPanel(WMScreen * scrPtr) void WMFreeColorPanel(WMColorPanel * panel) { - W_Screen *scr = WMWidgetScreen(panel->win); - - if (panel == scr->sharedColorPanel) { - scr->sharedColorPanel = NULL; - } + W_Screen *scr; if (!panel) return; + scr = WMWidgetScreen(panel->win); + if (panel == scr->sharedColorPanel) { + scr->sharedColorPanel = NULL; + } + WMRemoveNotificationObserver(panel); WMUnmapWidget(panel->win);