1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-21 13:28:05 +01:00

WPrefs: fix memory leak in buildPLFromMenu (Coverity #50105)

As pointed by Coverity, the PLArray that is created to store the return
value of the function 'processData' can be left allocated if some case
handling decide to return NULL instead.

Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This commit is contained in:
Christophe CURIS
2014-05-31 19:58:42 +02:00
committed by Carlos R. Mafra
parent dc2a991e21
commit a9e2923f67

View File

@@ -1557,7 +1557,7 @@ static WMPropList *processData(const char *title, ItemData * data)
switch (data->type) { switch (data->type) {
case ExecInfo: case ExecInfo:
if (data->param.exec.command == NULL) if (data->param.exec.command == NULL)
return NULL; goto return_null;
#if 1 #if 1
if (strpbrk(data->param.exec.command, "&$*|><?`=;")) { if (strpbrk(data->param.exec.command, "&$*|><?`=;")) {
s1 = "SHEXEC"; s1 = "SHEXEC";
@@ -1607,7 +1607,7 @@ static WMPropList *processData(const char *title, ItemData * data)
case PipeInfo: case PipeInfo:
case PLPipeInfo: case PLPipeInfo:
if (!data->param.pipe.command) if (!data->param.pipe.command)
return NULL; goto return_null;
if (data->type == PLPipeInfo) if (data->type == PLPipeInfo)
WMAddToPLArray(item, poplmenu); WMAddToPLArray(item, poplmenu);
else else
@@ -1623,18 +1623,19 @@ static WMPropList *processData(const char *title, ItemData * data)
case ExternalInfo: case ExternalInfo:
if (!data->param.external.path) if (!data->param.external.path)
return NULL; goto return_null;
WMAddToPLArray(item, pomenu); WMAddToPLArray(item, pomenu);
WMAddToPLArray(item, WMCreatePLString(data->param.external.path)); WMAddToPLArray(item, WMCreatePLString(data->param.external.path));
break; break;
case DirectoryInfo: case DirectoryInfo:
if (!data->param.directory.directory || !data->param.directory.command)
return NULL;
{ {
int l; int l;
char *tmp; char *tmp;
if (!data->param.directory.directory || !data->param.directory.command)
goto return_null;
l = strlen(data->param.directory.directory); l = strlen(data->param.directory.directory);
l += strlen(data->param.directory.command); l += strlen(data->param.directory.command);
l += 32; l += 32;
@@ -1665,6 +1666,10 @@ static WMPropList *processData(const char *title, ItemData * data)
} }
return item; return item;
return_null:
WMReleasePropList(item);
return NULL;
} }
static WMPropList *processSubmenu(WEditMenu * menu) static WMPropList *processSubmenu(WEditMenu * menu)