From 9f2f94a17420b97d81d45bbab9764fb2716a3e12 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Tue, 20 May 2014 21:46:36 +0200 Subject: [PATCH] WMaker: fix memory leak in root menu parser (Coverity #50123 and #50124) As pointed by Coverity, if an invalid OPEN_MENU is used then the memory allocated when parsing the line containing it would be leaked. Signed-off-by: Christophe CURIS --- src/rootmenu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rootmenu.c b/src/rootmenu.c index 8f0723cc..a922f5ea 100644 --- a/src/rootmenu.c +++ b/src/rootmenu.c @@ -627,6 +627,11 @@ static void constructMenu(WMenu * menu, WMenuEntry * entry) separateCommand((char *)entry->clientdata, &path, &cmd); if (path == NULL || *path == NULL || **path == 0) { wwarning(_("invalid OPEN_MENU specification: %s"), (char *)entry->clientdata); + if (path) { + for (i = 0; path[i] != NULL; i++) + wfree(path[i]); + wfree(path); + } if (cmd) wfree(cmd); return; @@ -747,6 +752,11 @@ static void constructPLMenuFromPipe(WMenu * menu, WMenuEntry * entry) if (path == NULL || *path == NULL || **path == 0) { wwarning(_("invalid OPEN_PLMENU specification: %s"), (char *)entry->clientdata); + if (path) { + for (i = 0; path[i] != NULL; i++) + wfree(path[i]); + wfree(path); + } if (cmd) wfree(cmd); return;