Hi all,

I hope this little patch will find its use.

Kind regards.
From 7bf231bf75280bf63d9c69f6f8a782257daf6ce8 Mon Sep 17 00:00:00 2001
From: David Carlier <[email protected]>
Date: Mon, 22 Aug 2016 23:27:42 +0100
Subject: [PATCH] MINOR: cfgparse: few memory leaks fixes.

Some minor memory leak during the config parsing.
---
 src/cfgparse.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/cfgparse.c b/src/cfgparse.c
index a65c701..fcb32ec 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1604,6 +1604,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int kwm)
 			if (logsrv->format < 0) {
 				Alert("parsing [%s:%d] : unknown log format '%s'\n", file, linenum, args[arg+3]);
 				err_code |= ERR_ALERT | ERR_FATAL;
+				free(logsrv);
 				goto out;
 			}
 
@@ -6841,9 +6842,10 @@ cfg_parse_users(const char *file, int linenum, char **args, int kwm)
 		}
 
 		ag->name = strdup(args[1]);
-		if (!ag) {
+		if (!ag->name) {
 			Alert("parsing [%s:%d]: out of memory.\n", file, linenum);
 			err_code |= ERR_ALERT | ERR_ABORT;
+			free(ag);
 			goto out;
 		}
 
@@ -6858,6 +6860,10 @@ cfg_parse_users(const char *file, int linenum, char **args, int kwm)
 				Alert("parsing [%s:%d]: '%s' only supports 'users' option.\n",
 				      file, linenum, args[0]);
 				err_code |= ERR_ALERT | ERR_FATAL;
+				if (ag->groupusers)
+					free(ag->groupusers);
+				free(ag->name);
+				free(ag);
 				goto out;
 			}
 		}
-- 
2.9.3

Reply via email to