Fixed possible null pointer dereference
authorChristophe CURIS <christophe.curis@free.fr>
Mon, 8 Oct 2012 23:19:15 +0000 (9 01:19 +0200)
committerCarlos R. Mafra <crmafra@gmail.com>
Mon, 8 Oct 2012 23:29:22 +0000 (9 00:29 +0100)
The new function 'unpaint_app_icon' checks its argument 'wapp' aginst NULL,
however it does dereference the pointer beforehand, which will end up in
a crash if the null-pointer case occurs.

src/appicon.c

index f2dc957..9bac0ef 100644 (file)
@@ -160,8 +160,8 @@ void makeAppIconFor(WApplication *wapp)
 void unpaint_app_icon(WApplication *wapp)
 {
        WAppIcon *aicon;
-       WScreen *scr = wapp->main_window_desc->screen_ptr;
-       WDock *clip = scr->workspaces[scr->current_workspace]->clip;
+       WScreen *scr;
+       WDock *clip;
 
        if (!wapp || !wapp->app_icon)
                return;
@@ -172,6 +172,9 @@ void unpaint_app_icon(WApplication *wapp)
        if (aicon->docked)
                return;
 
+       scr = wapp->main_window_desc->screen_ptr;
+       clip = scr->workspaces[scr->current_workspace]->clip;
+
        if (!clip || !aicon->attracted || !clip->collapsed)
                XUnmapWindow(dpy, aicon->icon->core->window);