mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 22:28:02 +01:00
wmaker: remove non-necessary allocation (Coverity #109609)
As pointed by Coverity, there was a memory leak because the buffer used to create the wmsetbg command is allocated twice. Because it is not really necessary to call 'wmalloc' for such a small case (it is not efficient and participates to memory fragmentation), this patch replaces the dynamic memory allocation by a buffer on the stack, which also solves to de-allocation issue. Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
04404bf47c
commit
d72e6d415a
@@ -3088,23 +3088,21 @@ static int setWorkspaceBack(WScreen * scr, WDefaultEntry * entry, void *tdata, v
|
||||
}
|
||||
}
|
||||
} else if (WMGetPropListItemCount(value) > 0) {
|
||||
char *command;
|
||||
char *text;
|
||||
char *dither;
|
||||
int len;
|
||||
|
||||
text = WMGetPropListDescription(value, False);
|
||||
len = strlen(text) + 40;
|
||||
command = wmalloc(len);
|
||||
dither = wPreferences.no_dithering ? "-m" : "-d";
|
||||
if (!strchr(text, '\'') && !strchr(text, '\\')) {
|
||||
command = wmalloc(len);
|
||||
char command[len];
|
||||
|
||||
if (wPreferences.smooth_workspace_back)
|
||||
snprintf(command, len, "wmsetbg %s -S -p '%s' &", dither, text);
|
||||
else
|
||||
snprintf(command, len, "wmsetbg %s -p '%s' &", dither, text);
|
||||
ExecuteShellCommand(scr, command);
|
||||
wfree(command);
|
||||
} else
|
||||
wwarning(_("Invalid arguments for background \"%s\""), text);
|
||||
wfree(text);
|
||||
|
||||
Reference in New Issue
Block a user