From c1e8bfb186c5cbeafbce9f2767db82edb579d5e1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 13 Mar 2015 14:12:41 +0000 Subject: [PATCH] ctdb: Fix memleak in ctdb_get_script_list scandir allocates every name individually, see example code in susv4 or man scandir Signed-off-by: Volker Lendecke Reviewed-by: Michael Adam --- ctdb/server/eventscript.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ctdb/server/eventscript.c b/ctdb/server/eventscript.c index 4cbb846ed9c..a47396a8ad9 100644 --- a/ctdb/server/eventscript.c +++ b/ctdb/server/eventscript.c @@ -177,8 +177,7 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb, + sizeof(scripts->scripts[0]) * count); if (scripts == NULL) { DEBUG(DEBUG_ERR, (__location__ " Failed to allocate scripts\n")); - free(namelist); - return NULL; + goto done; } scripts->num_scripts = count; @@ -191,6 +190,10 @@ static struct ctdb_scripts_wire *ctdb_get_script_list(struct ctdb_context *ctdb, } } +done: + for (i=0; i