mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 04:20:27 +01:00
util: fixed memleak in wmsetbg's updateDomain (Coverity #50167)
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.curis@free.fr>
This commit is contained in:
committed by
Carlos R. Mafra
parent
9cef8c882e
commit
e5ebe0cb92
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user