From: Christophe CURIS <christophe.cu...@free.fr>

As pointed by Coverity, if there's no window to unmap in a workspace, then
the array used to build the list of the windows to be unmapped for
workspace change would not be freed.

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 src/workspace.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/workspace.c b/src/workspace.c
index b0c436d..d58f904 100644
--- a/src/workspace.c
+++ b/src/workspace.c
@@ -472,8 +472,6 @@ void wWorkspaceRelativeChange(WScreen * scr, int amount)
 void wWorkspaceForceChange(WScreen * scr, int workspace)
 {
        WWindow *tmp, *foc = NULL, *foc2 = NULL;
-       WWindow **toUnmap;
-       int toUnmapSize, toUnmapCount;
 
        if (workspace >= MAX_WORKSPACES || workspace < 0)
                return;
@@ -492,16 +490,19 @@ void wWorkspaceForceChange(WScreen * scr, int workspace)
 
        wWorkspaceMenuUpdate(w_global.clip.ws_menu);
 
-       toUnmapSize = 16;
-       toUnmapCount = 0;
-       toUnmap = wmalloc(toUnmapSize * sizeof(WWindow *));
-
        if ((tmp = scr->focused_window) != NULL) {
+               WWindow **toUnmap;
+               int toUnmapSize, toUnmapCount;
+
                if ((IS_OMNIPRESENT(tmp) && (tmp->flags.mapped || 
tmp->flags.shaded) &&
                     !WFLAGP(tmp, no_focusable)) || 
tmp->flags.changing_workspace) {
                        foc = tmp;
                }
 
+               toUnmapSize = 16;
+               toUnmapCount = 0;
+               toUnmap = wmalloc(toUnmapSize * sizeof(WWindow *));
+
                /* foc2 = tmp; will fix annoyance with gnome panel
                 * but will create annoyance for every other application
                 */
-- 
1.9.2


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to