mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-20 04:48:06 +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;
|
int result;
|
||||||
char *program = "wdwrite";
|
char *program = "wdwrite";
|
||||||
|
char cmd_smooth[1024];
|
||||||
|
|
||||||
/* here is a mem leak */
|
snprintf(cmd_smooth, sizeof(cmd_smooth),
|
||||||
result = system(wstrconcat("wdwrite ",
|
"wdwrite %s SmoothWorkspaceBack %s",
|
||||||
wstrconcat(domain, smooth ? " SmoothWorkspaceBack YES" : " SmoothWorkspaceBack NO")));
|
domain, smooth ? "YES" : "NO");
|
||||||
|
result = system(cmd_smooth);
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
werror("error executing system command");
|
werror("error executing system(\"%s\")", cmd_smooth);
|
||||||
|
|
||||||
execlp(program, program, domain, key, texture, NULL);
|
execlp(program, program, domain, key, texture, NULL);
|
||||||
wwarning("warning could not run \"%s\"", program);
|
wwarning("warning could not run \"%s\"", program);
|
||||||
|
|||||||
Reference in New Issue
Block a user