From a9e2923f67a3256c5085c1d532a63b5e7f6da277 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sat, 31 May 2014 19:58:42 +0200 Subject: [PATCH] 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 --- WPrefs.app/Menu.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/WPrefs.app/Menu.c b/WPrefs.app/Menu.c index 59d407e3..afe8700d 100644 --- a/WPrefs.app/Menu.c +++ b/WPrefs.app/Menu.c @@ -1557,7 +1557,7 @@ static WMPropList *processData(const char *title, ItemData * data) switch (data->type) { case ExecInfo: if (data->param.exec.command == NULL) - return NULL; + goto return_null; #if 1 if (strpbrk(data->param.exec.command, "&$*|>param.pipe.command) - return NULL; + goto return_null; if (data->type == PLPipeInfo) WMAddToPLArray(item, poplmenu); else @@ -1623,18 +1623,19 @@ static WMPropList *processData(const char *title, ItemData * data) case ExternalInfo: if (!data->param.external.path) - return NULL; + goto return_null; WMAddToPLArray(item, pomenu); WMAddToPLArray(item, WMCreatePLString(data->param.external.path)); break; case DirectoryInfo: - if (!data->param.directory.directory || !data->param.directory.command) - return NULL; { int l; 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.command); l += 32; @@ -1665,6 +1666,10 @@ static WMPropList *processData(const char *title, ItemData * data) } return item; + + return_null: + WMReleasePropList(item); + return NULL; } static WMPropList *processSubmenu(WEditMenu * menu)