From d72e6d415a78972e9085841545f5de58e931b4f3 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 25 Apr 2015 12:44:25 +0200 Subject: [PATCH] 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 --- src/defaults.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/defaults.c b/src/defaults.c index ee027dc0..b6e855c0 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -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);