mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 12:28:22 +01:00
wmaker: fix memory leak in the Workspace Map if there is no workspace (Coverity #109608)
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 <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
ae07899122
commit
04404bf47c
10
src/wsmap.c
10
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)
|
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->border_width = 5;
|
||||||
wsmap->edge = edge;
|
wsmap->edge = edge;
|
||||||
wsmap->mini_workspace_width = scr->scr_width / WORKSPACE_MAP_RATIO;
|
wsmap->mini_workspace_width = scr->scr_width / WORKSPACE_MAP_RATIO;
|
||||||
wsmap->mini_workspace_height = scr->scr_height / WORKSPACE_MAP_RATIO;
|
wsmap->mini_workspace_height = scr->scr_height / WORKSPACE_MAP_RATIO;
|
||||||
|
|
||||||
if (scr->workspace_count == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
wsmap->scr = scr;
|
wsmap->scr = scr;
|
||||||
wsmap->win = WMCreateWindow(scr->wmscreen, "wsmap");
|
wsmap->win = WMCreateWindow(scr->wmscreen, "wsmap");
|
||||||
wsmap->wswidth = WidthOfScreen(DefaultScreenOfDisplay(dpy));
|
wsmap->wswidth = WidthOfScreen(DefaultScreenOfDisplay(dpy));
|
||||||
|
|||||||
Reference in New Issue
Block a user