As pointed by Coverity, there is a safety check on the number of workspace which aborts the function, but the storage memory have already been allocated so it would leak this buffer.
The case where the number of workspace is 0 is probably not supposed to happen (there should always be at least 1 workspace, the current one), but it is better to keep safety checks, so this patch is moving the check at the beginning so no leak will occur. Signed-off-by: Christophe CURIS <[email protected]> --- src/wsmap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wsmap.c b/src/wsmap.c index e2b6747..3e84c98 100644 --- a/src/wsmap.c +++ b/src/wsmap.c @@ -372,16 +372,18 @@ static void create_mini_workspace(WScreen *scr, WWorkspaceMap *wsmap, W_Workspac static WWorkspaceMap *create_workspace_map(WScreen *scr, W_WorkspaceMap *wsmap_array, int edge) { - WWorkspaceMap *wsmap = wmalloc(sizeof(WWorkspaceMap)); + WWorkspaceMap *wsmap; + + if (scr->workspace_count == 0) + return NULL; + + wsmap = wmalloc(sizeof(*wsmap)); wsmap->border_width = 5; wsmap->edge = edge; wsmap->mini_workspace_width = scr->scr_width / WORKSPACE_MAP_RATIO; wsmap->mini_workspace_height = scr->scr_height / WORKSPACE_MAP_RATIO; - if (scr->workspace_count == 0) - return NULL; - wsmap->scr = scr; wsmap->win = WMCreateWindow(scr->wmscreen, "wsmap"); wsmap->wswidth = WidthOfScreen(DefaultScreenOfDisplay(dpy)); -- 2.1.4 -- To unsubscribe, send mail to [email protected].
