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

As pointed by Coverity, the function wstrconcat is allocating memory to
return its result, which is not freed in old coding of the function.

This patch uses a local storage buffer to have a simpler code to generate
the command to bu run with 'system' without leak.

Signed-off-by: Christophe CURIS <christophe.cu...@free.fr>
---
 util/wmsetbg.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/util/wmsetbg.c b/util/wmsetbg.c
index 80a845e..41e1d11 100644
--- a/util/wmsetbg.c
+++ b/util/wmsetbg.c
@@ -992,13 +992,14 @@ static void updateDomain(const char *domain, const char 
*key, const char *textur
 {
        int result;
        char *program = "wdwrite";
+       char cmd_smooth[1024];
 
-       /* here is a mem leak */
-       result = system(wstrconcat("wdwrite ",
-                         wstrconcat(domain, smooth ? " SmoothWorkspaceBack 
YES" : " SmoothWorkspaceBack NO")));
-
+       snprintf(cmd_smooth, sizeof(cmd_smooth),
+                "wdwrite %s SmoothWorkspaceBack %s",
+                domain, smooth ? "YES" : "NO");
+       result = system(cmd_smooth);
        if (result == -1)
-               werror("error executing system command");
+               werror("error executing system(\"%s\")", cmd_smooth);
 
        execlp(program, program, domain, key, texture, NULL);
        wwarning("warning could not run \"%s\"", program);
-- 
1.9.2


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

Reply via email to